O
oop_dude
I'm trying to use a thread in the following situation, but having never
used threading before, I don't know where to begin.
My program has a timer set to fire every 10 seconds or so. In the tick
event I call a SQL Server stored procedure. As the stored proc has
grown in scope it sometimes takes more than 10 seconds to run.
When this happens a SECOND timer event fires before the first one
returns. This of course causes runtime errors (record conflicts) from
SQL Server.
I tried disabling the timer immediately upon entering the tick event
and then re-enabling it just prior to exiting the tick event. However,
doing this causes the program to become "sluggish", like menu
selections not responding properly, etc. A DoEvents would normally
help, but of course once the stored proc starts DoEvents doesn't work.
So, next thought is to make the tick event spawn a thread that in turn
calls the stored proc. Before spawing the thread to call the stored
proc, the tick event code should check to see if the previous thread is
still running. If so just exit out and try again during the firing of
the next tick event.
If someone could post a short snippet of code on how to accomplish
this, I'd be most appreciative.
tks
Oop
used threading before, I don't know where to begin.
My program has a timer set to fire every 10 seconds or so. In the tick
event I call a SQL Server stored procedure. As the stored proc has
grown in scope it sometimes takes more than 10 seconds to run.
When this happens a SECOND timer event fires before the first one
returns. This of course causes runtime errors (record conflicts) from
SQL Server.
I tried disabling the timer immediately upon entering the tick event
and then re-enabling it just prior to exiting the tick event. However,
doing this causes the program to become "sluggish", like menu
selections not responding properly, etc. A DoEvents would normally
help, but of course once the stored proc starts DoEvents doesn't work.
So, next thought is to make the tick event spawn a thread that in turn
calls the stored proc. Before spawing the thread to call the stored
proc, the tick event code should check to see if the previous thread is
still running. If so just exit out and try again during the firing of
the next tick event.
If someone could post a short snippet of code on how to accomplish
this, I'd be most appreciative.
tks
Oop