I have a GUI and only 1 background thread (constantly running). The GUI must be able to tell the bg thread to do some actions in between its work. Just like a GUI thread can do work when it's idling. I know normal threads aren't idling. Nevertheless I need to know: what are the possibilities here?
Changing to a GUI thread is simple when you have a control:
if (InvokeRequired)
this.Invoke(new Action<string>(thisMethod), new object[] { text });
else
{
// ...
}
Now - when the user clicks a button - how do I execute a method on a background thread that is already running? By background threads I'm referring to these guys:
new Thread(new ThreadStart(MyThread.Run)).Start();
ThreadPool.QueueUserWorkItem(o => { MyThread.Run(); });
I'm interested in both: Invoke- and BeginInvoke-style.
Thanks for the help!