I have 2 timers in MVB 2008 Express, one to control the fading in of a window and another to call a beep function every few seconds or so. The problem is that while the window is fading in, it pauses while the timer beeps. Any ideas? Threads maybe?
Share
Without seeing your code, I have a feeling that this is indeed related to threads.
It sounds like you have a Windows Application, with two
Timercontrols sited on a form. You probably have code within each timer’sTickevent to perform the relevant functionality, one to fade the form, the other to beep.What is happening here is that both of these functions defined in the
Tickevents are running in the same thread. This is the same thread that is used for your Windows Forms UI (user interface). You can see the same problem when trying to update some portion of your form (display) while attempting to execute a long running process – Usually all form updates “stop” or “hang” until that long running process is completed.To correct this problem, you’ll need to have one (if not both) of the code functions that are called when the
Timer‘s fire theirTickevents run in a separate thread.The easiest way to achieve this is via a BackgroundWorker component (or class). Alternatively, you can instantiate and use your own ThreadStart delegate (which is what the BackgroundWorker component does anyway!)
Something like the following: