Prepare for extremely stupid question!
-
Ok. I'm a C++ programmer (with a little VB6 experience) that's recently started using VB.NET quite a bit. I have to ask this even though I feel pretty certain that I don't have to worry about it... but I'm not sure just how large the changes are from VB to VB.NET so here we go... In VB.NET, if I use multiple Timer objects (the new one, not the Forms one) so I can have different times, is there any chance the timers could fire at the same time? Ie, VB.NET is still basically a single threaded application, right? Each run of a fired timer event will NOT be treated as a thread...? I'm just making sure. I'm thinking of doing something a certain way and some of the resources used in each timer are shared so I can't have them stepping on each other. Would another timer fire off while another one is running? Can I stop that behavior (if it exists) with some sort of locking mechanism like a Mutex in C++?
-
Ok. I'm a C++ programmer (with a little VB6 experience) that's recently started using VB.NET quite a bit. I have to ask this even though I feel pretty certain that I don't have to worry about it... but I'm not sure just how large the changes are from VB to VB.NET so here we go... In VB.NET, if I use multiple Timer objects (the new one, not the Forms one) so I can have different times, is there any chance the timers could fire at the same time? Ie, VB.NET is still basically a single threaded application, right? Each run of a fired timer event will NOT be treated as a thread...? I'm just making sure. I'm thinking of doing something a certain way and some of the resources used in each timer are shared so I can't have them stepping on each other. Would another timer fire off while another one is running? Can I stop that behavior (if it exists) with some sort of locking mechanism like a Mutex in C++?
Are you talking about the System.threading.Timer? If so, you should have a look at the MSDN regarding them. I just read this. Use a TimerCallback delegate to specify the methods associated with a Timer. The methods do not execute in the thread that created the timer; they execute in a separate thread that is automatically allocated by the system If you're talking about the System.Timers.Timer then you're also in trouble Note The event-handling method may be called even after the Stop method is called. The event-handling method may run on one thread at the same time that a call to the Stop method runs on another thread. This might result in the Elapsed event being raised even after the Stop method is called. To prevent this, use the SignalTime property to compare the time the event was raised to the time the Stop method was called. If the event was raised after the Stop method was called, do not process the event. Pete
Pete
Insert Sig. Here!