Often, I need to do an expensive task then display results. So I ramp up a thread. Is there less code, or a better way to doing this than I am currently using?
Example:
ThreadStart job = new ThreadStart (delegate {
Search d = new Search ();
x = d.DoSomeWork();
InvokeOnMainThread (delegate {
ctl.Show (x);
});
});
–start the thread here….
You can use the thread pool and simplify things a little bit.
ThreadPool.QueueUserWorkItem( delegate { /* … */ } );