Timer1_Tick is never fired

F

fniles

I have a main form who calls a worker thread. Inside the thread, I call
EnableTimer from the main form.
EnableTimer enable Timer1 in the main form. When I debug the program, it
goes to EnableTimer, and although it sets Timer1.Enabled = True and call
Timer1.Start(), Timer1_Tick is never fired.
Why is Timer1_Tick did not get called ? No matter I set the Interval of
Timer1 to 1 or 4000, Timer1_Tick is never fired.

Thank you.

Codes from the main form:
Public Class frmQuoteServer
Private Session As WorkerThread = Nothing
Private WorkerThread As Threading.Thread = Nothing
:
Session = New WorkerThread
WorkerThread = New Threading.Thread(AddressOf Session.ThreadMain)
' Initialize the client session object with the reference to
' this form, and the socket that was created
Session.ClientForm = Me

' Initialize the worker thread and start its execution
WorkerThread.Name = "WorkerThread"
WorkerThread.Start()
:
Public Sub EnableTimer()
Timer1.Enabled = True
Timer1.Start()
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TimerGlobex.Tick
Logon()
Timer1.Enabled = False
End Sub

Codes from the thread:
Public Class WorkerThread
Public ClientForm As frmServer = Nothing

Public Sub ThreadMain()

:
If bDisconnect Then ClientForm.EnableTimer()
Exit Sub
End Sub
 
C

Chris Dunaway

fniles said:
I have a main form who calls a worker thread. Inside the thread, I call
EnableTimer from the main form.
EnableTimer enable Timer1 in the main form. When I debug the program, it
goes to EnableTimer, and although it sets Timer1.Enabled = True and call
Timer1.Start(), Timer1_Tick is never fired.
Why is Timer1_Tick did not get called ? No matter I set the Interval of
Timer1 to 1 or 4000, Timer1_Tick is never fired.


Your timer tick event seems to handle the tick event from a timer
called TimerGlobex, but you are only enabling the timer for Timer1. Do
you have more than one timer?

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TimerGlobex.Tick
Logon()
Timer1.Enabled = False
End Sub

Where is the handler for Timer1?
 
F

fniles

I am sorry, a typo in this forum.

It should have been:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Logon()
Timer1.Enabled = False
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top