|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
timer controlhi all,
i m having some problem in timer control. sub timer.tick() timer.stop() do...something timer.enabled = true end sub this works fine. but after timer.stop() when i try to enable it from some other functions it doesnt work. and the timer stops forever thnx Hello Ratnesh,
> sub timer.tick() After calling timer.Stop(), you need to call timer.Start() to restart the > timer.stop() > do...something > timer.enabled = true > end sub timer. -- Jared Parsons [MSFT] jared***@online.microsoft.com All opinions are my own. All content is provided "AS IS" with no warranties, and confers no rights. thanks jared,
but that not working either. i've tried both ways, even both together. but no luck Show quoteHide quote "Jared Parsons [MSFT]" <jared***@online.microsoft.com> wrote in message news:61f143b4c7e8c86e527271e004@msnews.microsoft.com... > Hello Ratnesh, > >> sub timer.tick() >> timer.stop() >> do...something >> timer.enabled = true >> end sub > > After calling timer.Stop(), you need to call timer.Start() to restart the > timer. > -- > Jared Parsons [MSFT] > jared***@online.microsoft.com > All opinions are my own. All content is provided "AS IS" with no > warranties, and confers no rights. > > Hello Ratnesh,
> thanks jared, What happens when you call Start( exception, or just nothing). Try toggling > > but that not working either. i've tried both ways, even both together. > but no luck the Enabled and not calling Stop() at all. -- Jared Parsons [MSFT] jared***@online.microsoft.com All opinions are my own. All content is provided "AS IS" with no warranties, and confers no rights. when i call start or enabled=true. nothing happens in any case. but the tick
event doesnt fire after the interval. i've also tried to toggle the enabled property and didnt use Stop() still no luck. i dont know whats wrong. its like this sub timer.tick() timer.stop() [or timer.enabled=false] do...something enabletimersub() end sub sub enabletimersub() timer.enabled = true [or timer.start()] end sub thnx Show quoteHide quote "Jared Parsons [MSFT]" <jared***@online.microsoft.com> wrote in message news:61f143b4c938c86e57b7995103@msnews.microsoft.com... > Hello Ratnesh, > >> thanks jared, >> >> but that not working either. i've tried both ways, even both together. >> but no luck > > What happens when you call Start( exception, or just nothing). Try > toggling the Enabled and not calling Stop() at all. > -- > Jared Parsons [MSFT] > jared***@online.microsoft.com > All opinions are my own. All content is provided "AS IS" with no > warranties, and confers no rights. > > Hello Ratnesh,
Show quoteHide quote > when i call start or enabled=true. nothing happens in any case. but Can you post a code snippet that reproduces the issue?> the tick > event doesnt fire after the interval. > i've also tried to toggle the enabled property and didnt use Stop() > still no luck. i dont know whats wrong. > its like this > sub timer.tick() > timer.stop() [or timer.enabled=false] > do...something > enabletimersub() > end sub > sub enabletimersub() > timer.enabled = true [or timer.start()] > end sub -- Jared Parsons [MSFT] jared***@online.microsoft.com All opinions are my own. All content is provided "AS IS" with no warranties, and confers no rights. its a huge code. but i think i found the reason. herez the deal
can this be a problem? the do..something part runs on another thread which eventually calls the enabletimersub() so the main timer.tick() thread and enabletimersub() are on different threads. is there any solution for this sub timer.tick() timer.stop() [or timer.enabled=false] do...something end sub sub enabletimersub() timer.enabled = true [or timer.start()] end sub sorry for the delay in telling this point Show quoteHide quote "Jared Parsons [MSFT]" <jared***@online.microsoft.com> wrote in message news:61f143b4ce68c86e5bc88b419b@msnews.microsoft.com... > Hello Ratnesh, > >> when i call start or enabled=true. nothing happens in any case. but >> the tick >> event doesnt fire after the interval. >> i've also tried to toggle the enabled property and didnt use Stop() >> still no luck. i dont know whats wrong. >> its like this >> sub timer.tick() >> timer.stop() [or timer.enabled=false] >> do...something >> enabletimersub() >> end sub >> sub enabletimersub() >> timer.enabled = true [or timer.start()] >> end sub > > Can you post a code snippet that reproduces the issue? > > -- > Jared Parsons [MSFT] > jared***@online.microsoft.com > All opinions are my own. All content is provided "AS IS" with no > warranties, and confers no rights. > > Hello Ratnesh,
> its a huge code. but i think i found the reason. herez the deal That definately could be causing the behavior you are seeing. > > can this be a problem? > the do..something part runs on another thread which eventually calls > the > enabletimersub() > so the main timer.tick() thread and enabletimersub() are on different > threads. is there any solution for this The solution to this is to use Control.Invoke() to set Enabled on the thread the timer lives on. -- Jared Parsons [MSFT] jared***@online.microsoft.com All opinions are my own. All content is provided "AS IS" with no warranties, and confers no rights. thanks jared,
i found that too. but i m not sure how to use it. cna u show me in the snippet or give me any weblink for the help?? Private Sub enabletimersub() MsgBox("hi") tmr.Enabled = True End Sub Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick tmr.Stop() Dim thread1 As New System.Threading.Thread(AddressOf enabletimersub) thread1.Start() End Sub Show quoteHide quote "Jared Parsons [MSFT]" <jared***@online.microsoft.com> wrote in message news:61f143b4d378c86e6638720550@msnews.microsoft.com... > Hello Ratnesh, > >> its a huge code. but i think i found the reason. herez the deal >> >> can this be a problem? >> the do..something part runs on another thread which eventually calls >> the >> enabletimersub() >> so the main timer.tick() thread and enabletimersub() are on different >> threads. is there any solution for this > > That definately could be causing the behavior you are seeing. > The solution to this is to use Control.Invoke() to set Enabled on the > thread the timer lives on. > -- > Jared Parsons [MSFT] > jared***@online.microsoft.com > All opinions are my own. All content is provided "AS IS" with no > warranties, and confers no rights. > > Hello Ratnesh,
Show quoteHide quote > thanks jared, Assuming that Me is a Form or Control of some kind, try the following> i found that too. but i m not sure how to use it. cna u show me in the > snippet or give me any weblink for the help?? > Private Sub enabletimersub() > MsgBox("hi") > tmr.Enabled = True > End Sub > Private Sub tmr_Tick(ByVal sender As Object, ByVal e As > System.EventArgs) > Handles tmr.Tick > tmr.Stop() > Dim thread1 As New System.Threading.Thread(AddressOf > enabletimersub) > thread1.Start() > End Sub Sub enableTimerSub() Me.Invoke(CType(AddressOf enableTimerSubImpl, EventHandler)) End Sub Sub enableTimerSubImpl(ByVal object As Sender, ByVal e As EventArgs) tmr.Enabled = True End Sub Now you shoudl be able to call enableTimerSub() from the wrong thread and it will invoke and call enableTimerSubImpl on the correct thread. -- Jared Parsons [MSFT] jared***@online.microsoft.com All opinions are my own. All content is provided "AS IS" with no warranties, and confers no rights. thanks again and again
it works (finally) phew!! Show quoteHide quote "Jared Parsons [MSFT]" <jared***@online.microsoft.com> wrote in message news:61f143b4d468c86e6a45948593@msnews.microsoft.com... > Hello Ratnesh, > >> thanks jared, >> i found that too. but i m not sure how to use it. cna u show me in the >> snippet or give me any weblink for the help?? >> Private Sub enabletimersub() >> MsgBox("hi") >> tmr.Enabled = True >> End Sub >> Private Sub tmr_Tick(ByVal sender As Object, ByVal e As >> System.EventArgs) >> Handles tmr.Tick >> tmr.Stop() >> Dim thread1 As New System.Threading.Thread(AddressOf >> enabletimersub) >> thread1.Start() >> End Sub > > Assuming that Me is a Form or Control of some kind, try the following > > Sub enableTimerSub() > Me.Invoke(CType(AddressOf enableTimerSubImpl, EventHandler)) > End Sub > > Sub enableTimerSubImpl(ByVal object As Sender, ByVal e As EventArgs) > tmr.Enabled = True > End Sub > > Now you shoudl be able to call enableTimerSub() from the wrong thread and > it will invoke and call enableTimerSubImpl on the correct thread. > > -- > Jared Parsons [MSFT] > jared***@online.microsoft.com > All opinions are my own. All content is provided "AS IS" with no > warranties, and confers no rights. > > is it possible to do the same thing , If the timer control is in like class
module and not on any form. Show quoteHide quote "Jared Parsons [MSFT]" <jared***@online.microsoft.com> wrote in message news:61f143b4d468c86e6a45948593@msnews.microsoft.com... > Hello Ratnesh, > >> thanks jared, >> i found that too. but i m not sure how to use it. cna u show me in the >> snippet or give me any weblink for the help?? >> Private Sub enabletimersub() >> MsgBox("hi") >> tmr.Enabled = True >> End Sub >> Private Sub tmr_Tick(ByVal sender As Object, ByVal e As >> System.EventArgs) >> Handles tmr.Tick >> tmr.Stop() >> Dim thread1 As New System.Threading.Thread(AddressOf >> enabletimersub) >> thread1.Start() >> End Sub > > Assuming that Me is a Form or Control of some kind, try the following > > Sub enableTimerSub() > Me.Invoke(CType(AddressOf enableTimerSubImpl, EventHandler)) > End Sub > > Sub enableTimerSubImpl(ByVal object As Sender, ByVal e As EventArgs) > tmr.Enabled = True > End Sub > > Now you shoudl be able to call enableTimerSub() from the wrong thread and > it will invoke and call enableTimerSubImpl on the correct thread. > > -- > Jared Parsons [MSFT] > jared***@online.microsoft.com > All opinions are my own. All content is provided "AS IS" with no > warranties, and confers no rights. > > Hello Ratnesh,
> is it possible to do the same thing , If the timer control is in like You'll need a reference to a control on the foreground thread. Then you > class module and not on any form. can use thatControl.Invoke() to get onto the correct thread and reset the timer. -- Jared Parsons [MSFT] jared***@online.microsoft.com All opinions are my own. All content is provided "AS IS" with no warranties, and confers no rights. can you explain how?
bcoz the control doesnt seem to have the .invoke() method. i m running timer in the Main module. which calls another class as a saperate thread. thnx Show quoteHide quote "Jared Parsons [MSFT]" <jared***@online.microsoft.com> wrote in message news:61f143b51108c86efdf663197e@msnews.microsoft.com... > Hello Ratnesh, > >> is it possible to do the same thing , If the timer control is in like >> class module and not on any form. > > You'll need a reference to a control on the foreground thread. Then you > can use thatControl.Invoke() to get onto the correct thread and reset the > timer. > -- > Jared Parsons [MSFT] > jared***@online.microsoft.com > All opinions are my own. All content is provided "AS IS" with no > warranties, and confers no rights. > > Hello Ratnesh,
> can you explain how? Is control an instance of System.Windows.Forms.Conrol? If so it should have > bcoz the control doesnt seem to have the .invoke() method. > i m running timer in the Main module. which calls another class as a > saperate thread. an Invoke method. http://msdn2.microsoft.com/en-us/library/zyzhdc6b.aspx -- Jared Parsons [MSFT] jared***@online.microsoft.com All opinions are my own. All content is provided "AS IS" with no warranties, and confers no rights. jared,
i have the normal windows.forms.timer control. i've Main module with SubMain and this timer and few other things like contextmenu, trayicon etc now on timer.tick i m calling another class function on seperate thread. on end of that thread i want to start timer again. the problem is, if it was a form i could've called the invoke method simply. but here i dont know how to implement this. this is tray application, so it only stays in tray. thnx Show quoteHide quote "Jared Parsons [MSFT]" <jared***@online.microsoft.com> wrote in message news:61f143b53298c86f1cc51ac857@msnews.microsoft.com... > Hello Ratnesh, > >> can you explain how? >> bcoz the control doesnt seem to have the .invoke() method. >> i m running timer in the Main module. which calls another class as a >> saperate thread. > > Is control an instance of System.Windows.Forms.Conrol? If so it should > have an Invoke method. > > http://msdn2.microsoft.com/en-us/library/zyzhdc6b.aspx > > -- > Jared Parsons [MSFT] > jared***@online.microsoft.com > All opinions are my own. All content is provided "AS IS" with no > warranties, and confers no rights. > > Hello Ratnesh,
> jared, Add a shared field to your module of type System.Windows.Forms.Control. > > i have the normal windows.forms.timer control. > > i've Main module with SubMain and this timer and few other things like > contextmenu, trayicon etc > now on timer.tick i m calling another class function on seperate > thread. on > end of that thread i want to start timer again. > the problem is, if it was a form i could've called the invoke method > simply. > but here i dont know how to implement this. > this is tray application, so it only stays in tray. On the main thread (the one where you originally created the timers), addd the following lines mySharedControl = New Control() mySharedControl.CreateControl() Since mySharedControl is a shared field you can access it from your background method and use it to invoke back into the foreground thread. -- Jared Parsons [MSFT] jared***@online.microsoft.com All opinions are my own. All content is provided "AS IS" with no warranties, and confers no rights. here is the snippet
Private Sub enabletimersub() MsgBox("hi") tmr.Enabled = True End Sub Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick tmr.Stop() Dim thread1 As New System.Threading.Thread(AddressOf msgboxfun) thread1.Start() End Sub Show quoteHide quote "Jared Parsons [MSFT]" <jared***@online.microsoft.com> wrote in message news:61f143b4ce68c86e5bc88b419b@msnews.microsoft.com... > Hello Ratnesh, > >> when i call start or enabled=true. nothing happens in any case. but >> the tick >> event doesnt fire after the interval. >> i've also tried to toggle the enabled property and didnt use Stop() >> still no luck. i dont know whats wrong. >> its like this >> sub timer.tick() >> timer.stop() [or timer.enabled=false] >> do...something >> enabletimersub() >> end sub >> sub enabletimersub() >> timer.enabled = true [or timer.start()] >> end sub > > Can you post a code snippet that reproduces the issue? > > -- > Jared Parsons [MSFT] > jared***@online.microsoft.com > All opinions are my own. All content is provided "AS IS" with no > warranties, and confers no rights. > >
TreeView control checked based on if records exist
What exactly does it mean when they say CopyFile() and Progress Bar? CreateInstance and late binding what is best practice to populate large combobox? Q: Deleting a table with constraints Data binding to an object Somebody please help - Request for the permission of type 'System.Web.AspNetHostingPermission' [...] VB 2005 Newbie - Binding? No of files in folder |
|||||||||||||||||||||||