timer

  • Thread starter Thread starter usha
  • Start date Start date
U

usha

Hello ,

I have a program where i am using timers to refresh the databinded to
daatgrid for every 10 seconds.Along with this i am having other functions
for updating , sorting etc.

the program terminates while in run mode due when i try to do
updating/sorting since refreshing function will be happening simultaneously.

How to solve this, by which type of thread.?

regards
Thanks
Ushas
 
* "usha said:
I have a program where i am using timers to refresh the databinded to
daatgrid for every 10 seconds.Along with this i am having other functions
for updating , sorting etc.

the program terminates while in run mode due when i try to do
updating/sorting since refreshing function will be happening simultaneously.

Can you post some code?

Is an error message shown/exception thrown?
 
switch(refr)

{

case "10" :

{

timer1.Start();

break;

}

reseting the timer in one function, and one event of the timer where i am
rebinding the datedrid.

There is an option to update also so while it is rebinding for each 10
seconds , unhandled exception occurs.

regards

ushas
 
* "usha said:
There is an option to update also so while it is rebinding for each 10
seconds , unhandled exception occurs.

Can you post the complete exception text? It's important to be able to
determine the exception's reason.
 
Hi usha,

Which one of the three timers do you use. This simultaneous update/sorting
makes me thing that you use System,Threading.Timer and you try to update the
grid from different thread. With WinForms this is wrong.
 
Hello

I still not used any threads thats why the problem.
I am using 6 timer control.for different timing inputs, and firing the same
event of refreshing.

regards
usha
Stoitcho Goutsev (100) said:
Hi usha,

Which one of the three timers do you use. This simultaneous update/sorting
makes me thing that you use System,Threading.Timer and you try to update the
grid from different thread. With WinForms this is wrong.

--

Stoitcho Goutsev (100) [C# MVP]


usha said:
Hello ,

I have a program where i am using timers to refresh the databinded to
daatgrid for every 10 seconds.Along with this i am having other functions
for updating , sorting etc.

the program terminates while in run mode due when i try to do
updating/sorting since refreshing function will be happening simultaneously.

How to solve this, by which type of thread.?

regards
Thanks
Ushas
 
Hi usha

That's right. What I'm trying to tell you is that if you use Therading.Timer
or Timers.Timer classes execution of the callback method when time span
expires is done in a separate worker thread. With Timer.Timer you have
options It has one property SynchronizingObject that can be set to reference
some of your controls. In this case the callback (Elapsed event handler)
will be executed in the UI thread. BTW if you drag and drop this timer from
toolbox it will set that property for you.
If you use System.Windows.Forms.Timer, though, its Tick event handler is
always executed in the UI thread, but it is not quite accurate. In other
words with System.Windows.Forms.Timer you will never run into raceing
situations. The same goes for System.Timers.Timer if its SynchronizingObject
is set. If you use System.Threading.Timer, you do have multithread execution
and you have to sync your code.

--
HTH
Stoitcho Goutsev (100) [C# MVP]


usha said:
Hello

I still not used any threads thats why the problem.
I am using 6 timer control.for different timing inputs, and firing the same
event of refreshing.

regards
usha
Stoitcho Goutsev (100) said:
Hi usha,

Which one of the three timers do you use. This simultaneous update/sorting
makes me thing that you use System,Threading.Timer and you try to update the
grid from different thread. With WinForms this is wrong.

--

Stoitcho Goutsev (100) [C# MVP]


usha said:
Hello ,

I have a program where i am using timers to refresh the databinded to
daatgrid for every 10 seconds.Along with this i am having other functions
for updating , sorting etc.

the program terminates while in run mode due when i try to do
updating/sorting since refreshing function will be happening simultaneously.

How to solve this, by which type of thread.?

regards
Thanks
Ushas
 
Back
Top