Home All Groups Group Topic Archive Search About

Timer1_Tick is never fired

Author
16 Jun 2006 9:08 PM
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

Author
16 Jun 2006 9:12 PM
Chris Dunaway
fniles wrote:
> 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?
Author
16 Jun 2006 9:20 PM
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


Show quoteHide quote
"Chris Dunaway" <dunaw***@gmail.com> wrote in message
news:1150492341.379966.139910@f6g2000cwb.googlegroups.com...
> fniles wrote:
>> 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?
>
Author
17 Jun 2006 6:48 AM
Cor Ligthert [MVP]
Fniles,

For threading is the threading.timer

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemthreadingtimerclasstopic.asp

It has no tick event, which is in the form class, which can only be used on
forms.

Don't ask any help for the rest from me, I hate this threading timer and
will forever try to come around it.

Cor


Show quoteHide quote
"fniles" <fni***@pfmail.com> schreef in bericht
news:%2324lvqYkGHA.5108@TK2MSFTNGP02.phx.gbl...
>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
>
>
> "Chris Dunaway" <dunaw***@gmail.com> wrote in message
> news:1150492341.379966.139910@f6g2000cwb.googlegroups.com...
>> fniles wrote:
>>> 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?
>>
>
>