J
JL
Hi all,
I have a problem that I can't get rid off, and after many searches on the
Net I finally need your help! It seems like a basic multithreading thing,
but it's not as simple.
Let me explain the thing : I use a method with long time calculation. This
method comes from a SDK so I can't modify the code. My aim is to launch
this method, show a form that display the elapsed time, and enable the user
to use the mainform during the calculation. The problme I'm facing is that
the main form doesn't redraw during the calculation.
I tried several things :
- using a backgroundworker for the long method and a thread for the "elapsed
time form" with a timer within. The "elapsed time form" starts a timer that
forces the redraw with the new time --> if I use ElapsedTimeForm.Show the
"elapsed time form" isn't redrawn. If i use ElapsedTimeForm.ShowDialog the
"elapsed time form" is redrawn but the mainform is freezed (modal dialog,
normal).
- using a backgroundworker for the long method and a System.Threading.Timer
that would change the main form text with the elapsed time --> the mainform
isn't redrawn during the calculation.
- several crappy things![Smile :) :)](/styles/default/custom/smilies/smile.gif)
My main issue is that I can't use a backgroundwork with the reportprogress
and all stuff because my calculation method is "in one block", no way to
stop, pause, or do something from this method.
I have read many articles on multithreading in C#, and I really can't find
the good way to do this.
Anyone can help ?
Thanks !
I have a problem that I can't get rid off, and after many searches on the
Net I finally need your help! It seems like a basic multithreading thing,
but it's not as simple.
Let me explain the thing : I use a method with long time calculation. This
method comes from a SDK so I can't modify the code. My aim is to launch
this method, show a form that display the elapsed time, and enable the user
to use the mainform during the calculation. The problme I'm facing is that
the main form doesn't redraw during the calculation.
I tried several things :
- using a backgroundworker for the long method and a thread for the "elapsed
time form" with a timer within. The "elapsed time form" starts a timer that
forces the redraw with the new time --> if I use ElapsedTimeForm.Show the
"elapsed time form" isn't redrawn. If i use ElapsedTimeForm.ShowDialog the
"elapsed time form" is redrawn but the mainform is freezed (modal dialog,
normal).
- using a backgroundworker for the long method and a System.Threading.Timer
that would change the main form text with the elapsed time --> the mainform
isn't redrawn during the calculation.
- several crappy things
![Smile :) :)](/styles/default/custom/smilies/smile.gif)
My main issue is that I can't use a backgroundwork with the reportprogress
and all stuff because my calculation method is "in one block", no way to
stop, pause, or do something from this method.
I have read many articles on multithreading in C#, and I really can't find
the good way to do this.
Anyone can help ?
Thanks !