Hi,
I was trying to do something in a Thread that starts by a
timer. I turn off the timer at the begining of the thread
incase it fires again when the thread is still running. Then
turn on the timer again before the thread finishes. To my
surprise, the timer never come alive again once it has been
turned of in the thread. To test the problem I made a simple
Windows Form project, put a Beep() in the timer. It supposed
to hear beep beep beep every one seconds, but can only hear
one. Here enclosed my clode below. Any help or suggestions are
really appreciated.
Regards,
Vincent
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal _
e As System.EventArg s) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal _
e As System.EventArg s) Handles Timer1.Tick
Beep()
Dim thr As New Threading.Threa d(AddressOf ProcTest)
thr.Start()
End Sub
Private Sub ProcTest()
Timer1.Enabled = False
'Timer1.Stop()
Timer1.Enabled = True
'Timer1.Start()
End Sub 10 27693
Hi Vincent,
There are 3 timers
windows.forms.f orm.timer
System.timers.t imer
System.threadin g.timer
The one you are using now is as far as I can see the
windows.forms.f orm.timer and I think not the one the most suitable for your
problem.
Cor
Hi Vincent,
There are 3 timers
windows.forms.f orm.timer
System.timers.t imer
System.threadin g.timer
The one you are using now is as far as I can see the
windows.forms.f orm.timer and I think not the one the most suitable for your
problem.
Cor
"Cor Ligthert" <no**********@p lanet.nl> wrote in
news:et******** ******@TK2MSFTN GP10.phx.gbl: Hi Vincent,
There are 3 timers windows.forms.f orm.timer System.timers.t imer System.threadin g.timer
The one you are using now is as far as I can see the windows.forms.f orm.timer and I think not the one the most suitable for your problem.
Cor
Thanks for your suggestion. The System.threadin g.timer works great! Just
curious, I also tried System.timers.t imer, that works as well.
Don't understand why the System.Windows. Forms.Timer has the strange
problem. Maybe it is by design, but why vb.net doesn't give a compile error
or warning something. I wonder if it does the same thing in C#.
"Cor Ligthert" <no**********@p lanet.nl> wrote in
news:et******** ******@TK2MSFTN GP10.phx.gbl: Hi Vincent,
There are 3 timers windows.forms.f orm.timer System.timers.t imer System.threadin g.timer
The one you are using now is as far as I can see the windows.forms.f orm.timer and I think not the one the most suitable for your problem.
Cor
Thanks for your suggestion. The System.threadin g.timer works great! Just
curious, I also tried System.timers.t imer, that works as well.
Don't understand why the System.Windows. Forms.Timer has the strange
problem. Maybe it is by design, but why vb.net doesn't give a compile error
or warning something. I wonder if it does the same thing in C#.
"Vincent" <Ja***@serbe.co m> schrieb Hi,
I was trying to do something in a Thread that starts by a timer. I turn off the timer at the begining of the thread incase it fires again when the thread is still running. Then turn on the timer again before the thread finishes. To my surprise, the timer never come alive again once it has been turned of in the thread. To test the problem I made a simple Windows Form project, put a Beep() in the timer. It supposed to hear beep beep beep every one seconds, but can only hear one. Here enclosed my clode below. Any help or suggestions are really appreciated.
Regards, Vincent
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal _ e As System.EventArg s) Handles MyBase.Load Timer1.Interval = 1000 Timer1.Enabled = True End Sub
Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal _ e As System.EventArg s) Handles Timer1.Tick Beep() Dim thr As New Threading.Threa d(AddressOf ProcTest) thr.Start() End Sub
Private Sub ProcTest() Timer1.Enabled = False 'Timer1.Stop() Timer1.Enabled = True 'Timer1.Start() End Sub
You must access the timer from the thread that created the timer.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
"Vincent" <Ja***@serbe.co m> schrieb Hi,
I was trying to do something in a Thread that starts by a timer. I turn off the timer at the begining of the thread incase it fires again when the thread is still running. Then turn on the timer again before the thread finishes. To my surprise, the timer never come alive again once it has been turned of in the thread. To test the problem I made a simple Windows Form project, put a Beep() in the timer. It supposed to hear beep beep beep every one seconds, but can only hear one. Here enclosed my clode below. Any help or suggestions are really appreciated.
Regards, Vincent
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal _ e As System.EventArg s) Handles MyBase.Load Timer1.Interval = 1000 Timer1.Enabled = True End Sub
Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal _ e As System.EventArg s) Handles Timer1.Tick Beep() Dim thr As New Threading.Threa d(AddressOf ProcTest) thr.Start() End Sub
Private Sub ProcTest() Timer1.Enabled = False 'Timer1.Stop() Timer1.Enabled = True 'Timer1.Start() End Sub
You must access the timer from the thread that created the timer.
--
Armin
How to quote and why: http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Hi Cor, windows.forms .form.timer
Whenever time is elapsed it puts an event in the message queue and
windows will work on one message after one. Suppose you have set timer
interval at 200ms there is not guarantee that it will come to ur
Timertick event at 200 ms
System.timers .timer
This runs on the forms thread and also has the accuracy of time so
timertick event will happen after 200 ms
System.thread ing.timer
This runs on a different thread but has the same functionlity as
systems.timer.t ime so we need to be careful while updating the form
variables as windows forms are not thread safe.
Regards
Sobhan
Jabco <Ja***@serbe.co m> wrote in message news:<Xn******* *************** ****@207.46.248 .16>... "Cor Ligthert" <no**********@p lanet.nl> wrote in news:et******** ******@TK2MSFTN GP10.phx.gbl:
Hi Vincent,
There are 3 timers windows.forms.f orm.timer System.timers.t imer System.threadin g.timer
The one you are using now is as far as I can see the windows.forms.f orm.timer and I think not the one the most suitable for your problem.
Cor
Thanks for your suggestion. The System.threadin g.timer works great! Just curious, I also tried System.timers.t imer, that works as well.
Don't understand why the System.Windows. Forms.Timer has the strange problem. Maybe it is by design, but why vb.net doesn't give a compile error or warning something. I wonder if it does the same thing in C#.
Hi Cor, windows.forms .form.timer
Whenever time is elapsed it puts an event in the message queue and
windows will work on one message after one. Suppose you have set timer
interval at 200ms there is not guarantee that it will come to ur
Timertick event at 200 ms
System.timers .timer
This runs on the forms thread and also has the accuracy of time so
timertick event will happen after 200 ms
System.thread ing.timer
This runs on a different thread but has the same functionlity as
systems.timer.t ime so we need to be careful while updating the form
variables as windows forms are not thread safe.
Regards
Sobhan
Jabco <Ja***@serbe.co m> wrote in message news:<Xn******* *************** ****@207.46.248 .16>... "Cor Ligthert" <no**********@p lanet.nl> wrote in news:et******** ******@TK2MSFTN GP10.phx.gbl:
Hi Vincent,
There are 3 timers windows.forms.f orm.timer System.timers.t imer System.threadin g.timer
The one you are using now is as far as I can see the windows.forms.f orm.timer and I think not the one the most suitable for your problem.
Cor
Thanks for your suggestion. The System.threadin g.timer works great! Just curious, I also tried System.timers.t imer, that works as well.
Don't understand why the System.Windows. Forms.Timer has the strange problem. Maybe it is by design, but why vb.net doesn't give a compile error or warning something. I wonder if it does the same thing in C#.
Vincent,
In addition to the others comments, the following recent articles in MSDN
Magazine explain the difference between the three thread objects in .NET &
when to use each. http://msdn.microsoft.com/msdnmag/is...T/default.aspx http://msdn.microsoft.com/msdnmag/is...3/default.aspx
Hope this helps
Jay
And yes, C# will exhibit the same basic behavior.
Hope this helps
Jay
"Vincent" <Ja***@serbe.co m> wrote in message
news:Xn******** *************** ***@207.46.248. 16... Hi,
I was trying to do something in a Thread that starts by a timer. I turn off the timer at the begining of the thread incase it fires again when the thread is still running. Then turn on the timer again before the thread finishes. To my surprise, the timer never come alive again once it has been turned of in the thread. To test the problem I made a simple Windows Form project, put a Beep() in the timer. It supposed to hear beep beep beep every one seconds, but can only hear one. Here enclosed my clode below. Any help or suggestions are really appreciated.
Regards, Vincent
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal _ e As System.EventArg s) Handles MyBase.Load Timer1.Interval = 1000 Timer1.Enabled = True End Sub
Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal _ e As System.EventArg s) Handles Timer1.Tick Beep() Dim thr As New Threading.Threa d(AddressOf ProcTest) thr.Start() End Sub
Private Sub ProcTest() Timer1.Enabled = False 'Timer1.Stop() Timer1.Enabled = True 'Timer1.Start() End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: brian |
last post by:
I have an ASP.Net application that uses impersonation.
This works fine for accessing/executing the application.
However, the app utilizes a timer, that when fired uses
the <machine>ASPNET identity.
In order to correct this problem I've modified the
Machine.config file in the
\Microsoft.Net\Framework\v1.1.4322 folder. However, this
didn't solve the problem; instead of using the user id and
password specified in Machine.Config, the...
|
by: bob |
last post by:
Could someone tell me how to create a Timer thread that calls a
function 60 times a second in VC++?
Thanks.
|
by: Todd |
last post by:
I have an ASP.NET application and I would like to have some code run
on the server automatically once a day at a specified time.
I create a timer thread to call a simple callback in the
Application_Start method. It seems to call the callback once or twice
while the application starts up but appears to stop once the default
page is displayed. Here is the code below (from Global.asax.cs):
public static void ProcessAccounts (object state)...
|
by: Vincent |
last post by:
Hi,
I was trying to do something in a Thread that starts by a
timer. I turn off the timer at the begining of the thread
incase it fires again when the thread is still running. Then
turn on the timer again before the thread finishes. To my
surprise, the timer never come alive again once it has been
turned of in the thread. To test the problem I made a simple
Windows Form project, put a Beep() in the timer. It supposed
to hear beep beep...
|
by: Tony Gravagno |
last post by:
I have a class that instantiates two Timer objects that fire at
different intervals. My class can be instantiated within a Windows
Form or from a Windows Service. Actions performed by one of the event
handlers may take longer than the interval for either of the timers,
so it's possible for multiple events to fire "simultaneously" and for
events to queue up. I'm attempting to get the timers to sync on some
reference type object, or use...
| |
by: mavrik |
last post by:
Hi all,
I have an application written in C, which runs on Sun OS platform. I had to port this application from Sun OS to Linux AS.
My whoe application works fine, but it gives some problem in Timer thread of one function.
What can be the reason, I've done all types of debugging and could not find any clue.
-Thanks
|
by: Michael Howes |
last post by:
I and trying to detect idle time or sorts in the applications I'm
building.
To do this the main Form also inherits from IMessageFilter and I
listen for WM_MOUSEMOVE. When that happens I reset a DateTime.
To check the time between last mouse move I have a timer
(System.Threading.Timer)
If the the DateTime math meets a certain threshold I want to show our
login dialog, essentially locking people out of this unattended app.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |