G
Guest
Hi,
I have created a thread to execute my task but for some readon the
application still locks up until the task is completed.Here is my sample code
code on button
Private Sub cmd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdImport.Click
Dim t As New Thread(AddressOf ExecuteTask)
t.Priority = ThreadPriority.Normal
t.Start()
End Sub
Ecexute task
Protected Sub ExecuteTask()
Dim sMessage As String
Dim lErr As Long, sSource As String, sDesc As String
oDts = New DTSPkg80.Package2Class
Try
oDts.LoadFromSQLServer("machine", "sa", "",
DTSPkg80.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, , , , "NewPackage")
For Each oStep In oDts.Steps
oStep.ExecuteInMainThread = True
Next
oDts.Execute()
For Each oStep In oDts.Steps
If oStep.ExecutionResult =
DTSPkg80.DTSStepExecResult.DTSStepExecResult_Failure Then
oStep.GetExecutionErrorInfo(lErr, sSource, sDesc)
sMessage = oStep.Name & " Failed"
Dim itmp As New Windows.Forms.ListViewItem(sMessage)
itmp.ImageIndex = 0
ListView1.Items.Add(itmp)
Else
sMessage = oStep.Name & " Succeeded"
End If
Next
oDts.UnInitialize()
Catch ex As Exception
MsgBox(ex.Message)
Finally
oStep = Nothing
oDts = Nothing
End Try
The program basically executes a package in sql server and displays the
messages (error or success) in a listview control. Wehn I run the program it
still locks up but runs perfect with the listview.
Any ideas?
I have created a thread to execute my task but for some readon the
application still locks up until the task is completed.Here is my sample code
code on button
Private Sub cmd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdImport.Click
Dim t As New Thread(AddressOf ExecuteTask)
t.Priority = ThreadPriority.Normal
t.Start()
End Sub
Ecexute task
Protected Sub ExecuteTask()
Dim sMessage As String
Dim lErr As Long, sSource As String, sDesc As String
oDts = New DTSPkg80.Package2Class
Try
oDts.LoadFromSQLServer("machine", "sa", "",
DTSPkg80.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, , , , "NewPackage")
For Each oStep In oDts.Steps
oStep.ExecuteInMainThread = True
Next
oDts.Execute()
For Each oStep In oDts.Steps
If oStep.ExecutionResult =
DTSPkg80.DTSStepExecResult.DTSStepExecResult_Failure Then
oStep.GetExecutionErrorInfo(lErr, sSource, sDesc)
sMessage = oStep.Name & " Failed"
Dim itmp As New Windows.Forms.ListViewItem(sMessage)
itmp.ImageIndex = 0
ListView1.Items.Add(itmp)
Else
sMessage = oStep.Name & " Succeeded"
End If
Next
oDts.UnInitialize()
Catch ex As Exception
MsgBox(ex.Message)
Finally
oStep = Nothing
oDts = Nothing
End Try
The program basically executes a package in sql server and displays the
messages (error or success) in a listview control. Wehn I run the program it
still locks up but runs perfect with the listview.
Any ideas?