|
-
May 15th, 2007, 04:24 PM
#1
Forms Timer and Thread problem
Hi,
I have an application which contains a form with a Forms.Timer. For some reason, the tick event is not getting called... Somehow this is connected to the fact that I start a new thread...
Here are some code snippets.
Code:
Private Sub tmrSchedule_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSchedule.Tick
Dim processor As New EDIProcessor
AddHandler processor.ProcessingComplete, AddressOf EDIProcessor_ProcessingComplete
If tmrSchedule.Enabled Then tmrSchedule.Stop()
ediWorker = New Thread(AddressOf processor.Run)
ediWorker.Start()
last = 0
'Call Me.EDIProcessor_ProcessingComplete("")
End Sub
Public Sub EDIProcessor_ProcessingComplete(ByVal msg As String)
'Do we need to somehow remove handlers here?
lstInfo.Items.Add("Process Complete " & msg)
Call scroll()
tmrSchedule.Enabled = True
tmrSchedule.Start()
pnlTransaction.Text = ""
End Sub
I disable the timer in the timer tick and enable it again when the processing is complete. I don't understand it, but the timer never fires after that, even though tmrSchedule.Enabled = true, and the interval is set to 20000, so it should be called again 20 seconds after the thread calls the Processing_Complete Event. Processing_Complete event is fired, and everything executes, but tmrSchedule.Tick is never fired again.
tmrSchedule is a Forms timer and not a threading timer. Also, I commented out the creation and starting of the thread, and the timer worked... I do not reference the timer in any other code in the application...
Any clues on why this would happen?
Thanks,
Ranthalion
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|