wsyeager
Centurion
I am able to successfully execute a thread. However, I notice that when the thread is executing, the hourglass is off (which is expected), but I can't seem to select any other menu items in my MDI application while the thread is executing. I can do other stuff with Windows outside of my application, but not from within my MDI app. Why???
I have another process in my MDI app that uses threading (where I don't need to create a delegate and I can access other menu items in my MDI app while the thread is executing).
Here is my code in regards to the first item I talked about above where I had to create a delegate (1st paragraph):
Does any body know why I can't select any other items from within my application while this thread is executing???
I have another process in my MDI app that uses threading (where I don't need to create a delegate and I can access other menu items in my MDI app while the thread is executing).
Here is my code in regards to the first item I talked about above where I had to create a delegate (1st paragraph):
Visual Basic:
Private thdPendingRpts As Thread
.
.
.
Private Sub btnRpt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRpt.Click
Try
thdPendingRpts = New Thread(New ThreadStart(AddressOf ThreadProc))
thdPendingRpts.IsBackground = True
thdPendingRpts.Priority = ThreadPriority.AboveNormal
thdPendingRpts.Name = "Pending Reports"
thdPendingRpts.Start()
StatusBar1.Text = "Thread 'Pending Reports' has started"
Catch exException As ThreadInterruptedException
StatusBar1.Text = exException.Message
Catch exException As ThreadStateException
StatusBar1.Text = exException.Message
Catch exException As ThreadAbortException
StatusBar1.Text = exException.Message
Catch exException As System.Exception
StatusBar1.Text = exException.Message
End Try
End Sub
Private Sub ThreadProc()
Try
Dim mi As New MethodInvoker(AddressOf ProcessData)
Me.Invoke(mi)
Catch exException As ThreadInterruptedException
StatusBar1.Text = exException.Message
Catch exException As ThreadStateException
StatusBar1.Text = exException.Message
Catch exException As ThreadAbortException
StatusBar1.Text = exException.Message
Catch exException As System.Exception
StatusBar1.Text = exException.Message
End Try
End Sub
Private Sub ProcessData()
btnRpt.Enabled = False
StatusBar1.Text = "Retrieving SQL1 data..."
DsOrdStatDlyRptPend1.Clear()
BuildSQL1()
If Not blnError Then
For i = 0 To DsOrdStatDlyRptPend1.OrdStatDlyRptPendSQL1.Rows.Count - 1
StatusBar1.Text = "Retrieving SQL2 data..."
BuildSQL2()
Next
If Not blnError Then
For i = 0 To DsOrdStatDlyRptPend1.OrdStatDlyRptPendSQL1.Rows.Count - 1
StatusBar1.Text = "Retrieving SQL3 data..."
BuildSQL3()
Next
If Not blnError Then
For i = 0 To DsOrdStatDlyRptPend1.OrdStatDlyRptPendSQL1.Rows.Count - 1
StatusBar1.Text = "Retrieving SQL4 data..."
BuildSQL4()
Next
If Not blnError Then
StatusBar1.Text = "Generating report..."
BuildReport()
End If
End If
End If
End If
StatusBar1.Text = "Thread 'Pending Reports' has finished"
btnRpt.Enabled = True
thdPendingRpts = Nothing
End Sub
Last edited by a moderator: