Re: Invoking UI from woker thread.
- From: Erakis <Erakis@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 20 May 2009 08:30:01 -0700
Hi,
Thanks for your answer.
The delay here is to slow down the process because the script process must
send command (one by one) to an automate. Perhaps a 200 millisecons should do
the trick.
So you advise me to make a WaitAll of 0 milliseconds and manage the time in
the while loop ? Using tick or something else ?
You tell me to make the stop button set the stop event. But it is what I do
actually ?
private void m_Bt_Stop_Click(object sender, System.EventArgs e)
{
...
m_EventStopThread.Set();
...
}
I don't understand why should I implement a lock mechanism here ? Could you
give me more details on that ?
Best regards,
Martin
"not_a_commie" wrote:
Your main UI thread is stuck in a WaitAll for 10ms at a time, and the.
delay may be longer depending on the CPU cores available, etc. You
should have your play button enabled and your stop button disabled
from inside your thread. Just make the stop button set the stop event.
And I don't really understand your delay stuff in the thread or your
DoEvents calls there. I would think you would just check the stop
event state (aka, use a timeout of 0) each time you passed through
your loop. And as far as those events go, performance wise you are
much better off using the Interlocked class or a common lock
mechanism. The ManualResetEvent is three orders of magnitude slower
than the lock keyword (Monitor class).
- References:
- Invoking UI from woker thread.
- From: Erakis
- Re: Invoking UI from woker thread.
- From: not_a_commie
- Invoking UI from woker thread.
- Prev by Date: Re: Invoking UI from woker thread.
- Next by Date: Re: C# read the values of a Fortran 95 type/struct?
- Previous by thread: Re: Invoking UI from woker thread.
- Next by thread: Re: Invoking UI from woker thread.
- Index(es):
Relevant Pages
|