I've a timer (interval = 1000) in my app. When the timer is working parallelly a big loop is also working. but I found out untile this loop not finished the timer won't work. How can I force the timer to alwasy work every second
I found this article about using threads in c# (http://abstractvb.com/code.asp A=1028) but when I tried to compile this sample the compiler return this error: The type or namespace name 'CallBack' could not be found (are you missing a using directive or an assembly reference )
In your big other loop, try calling Application.DoEvents() for every iteration.
Timers are based on (I think) windows messages - and so, they need a message loop to be running to process these windows messages. When you have this big loop, your thread is spending all the time on this big loop and the message loop never gets time to process the messages in the queue. Calling Application.DoEvents() will forces the message loop to process the messsages in the queue.
Thanks for your great solution. But sometimes we can't do this. e.x. when We orfer an OleDbCommand to execute a query. Untile OleDbCommand is running this query we can't call Application.DoEvents() but we need timer to works on it's time. What we can do in this case
Usually in that case, you would create a new thread and run the DB Query in the new thread. It's generally a good idea to keep the UI thread separate from the worker thread.
timer problem
jpvalappil
The type or namespace name 'CallBack' could not be found (are you missing a using directive or an assembly reference )
Tomáš Pajonk
Timers are based on (I think) windows messages - and so, they need a message loop to be running to process these windows messages. When you have this big loop, your thread is spending all the time on this big loop and the message loop never gets time to process the messages in the queue. Calling Application.DoEvents() will forces the message loop to process the messsages in the queue.
aalexander
But sometimes we can't do this. e.x. when We orfer an OleDbCommand to execute a query.
Untile OleDbCommand is running this query we can't call Application.DoEvents() but we need timer to works on it's time.
What we can do in this case
Raymunco Chapa G
Georgia Nelson
Shilps
Abel Valadez
MauroM
bhan