Application.Run

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello there,
I've created a worker thread that will handle events.
To give this worker thead a run loop i've called
Application.Run();

What call should i make to cause this thread to leave its run loop?

thanks
Brian
 
Thanks, but how can i call this from the Thread,

I.e. if my mail GUI thread is closing then
1) OnClosing () { .. try stop worker thread... wait for join on worker thread)

If i just call Application.ExitThread() in my GUI thread it will try exit
the wrong thread, any ideas on how i call this function in the context of my
Worker thread?
 
Thanks, but how can i call this from the Thread,

Given a reference to a control or form created on that thread, you can
use Control.Invoke (or BeginInvoke) to run a method on that thread
which in turn calls ExitThread.



Mattias
 
Thanks Mattias,
My worker thread wasn't derived from Control so I could not do this. (which
makes me assume that Application.Run should only be called on a Conrol or
control derived class.

Seems P/Inovke and PostThreadMessage etc would be one way or else use a
consumer producer with a method queue are only options.

However I've switched to using the thread pool and async delegates for my
task.

Thanks very much for your help
brian keating
www.briankeating.net
 
Back
Top