B
Bill
This one has me stumped. I'm using sample code in the C# Programmer's
Cookbook as a guide. Specifially, Recipe 4.3, Execute a Method Using a
Timer.
I created a form with a ProgressBar on it (Min=0, Max=100). When I
created my Timer object I passed the ProgressBar as the second
parameter, the "state" object. This object is passed to the
TimerHandler.
Inside the TimerHandler I increment ProgressBar.Value by 1 unless its
at the Max value, in which case I reset it to the Min value.\
I expected to see the ProgressBar grow in the form, but nothing
happened.
I set a few breakpoints and discovered that indeed the ProgressBar
object is being passed through the Timer object to the TimerHandler
method. However, in the TimerHandler the ProgressBar object is always
in its initial state.
This leads me to believe I'm getting a COPY of the ProgressBar object
in my TimerHandler.
As an experiment I left the Timer object out of the loop and called
TimerHandler directly from a loop and it worked perfectly.
I'm guessing my "problem" is rooted in the fact that I'm trying to
modify an object across threads.
Does anyone have any ideas what I'm doing wrong or how I might
accomplish my goal?
Thanks,
Bill...
Cookbook as a guide. Specifially, Recipe 4.3, Execute a Method Using a
Timer.
I created a form with a ProgressBar on it (Min=0, Max=100). When I
created my Timer object I passed the ProgressBar as the second
parameter, the "state" object. This object is passed to the
TimerHandler.
Inside the TimerHandler I increment ProgressBar.Value by 1 unless its
at the Max value, in which case I reset it to the Min value.\
I expected to see the ProgressBar grow in the form, but nothing
happened.
I set a few breakpoints and discovered that indeed the ProgressBar
object is being passed through the Timer object to the TimerHandler
method. However, in the TimerHandler the ProgressBar object is always
in its initial state.
This leads me to believe I'm getting a COPY of the ProgressBar object
in my TimerHandler.
As an experiment I left the Timer object out of the loop and called
TimerHandler directly from a loop and it worked perfectly.
I'm guessing my "problem" is rooted in the fact that I'm trying to
modify an object across threads.
Does anyone have any ideas what I'm doing wrong or how I might
accomplish my goal?
Thanks,
Bill...