The general task is to do something in the background thread, then when it is done, transfer the results to the user interface thread and tell the user.
I understand that there are two general ways:
I can use TPL:
var context = TaskScheduler.FromCurrentSynchronizationContext (); Task.Factory.StartNew (() => { DoSomeExpensiveTask(); return "Hi Mom"; }).ContinueWith (t => { DoSomethingInUI(t.Result); }, context);
Or Old ThreadPool:
ThreadPool.QueueUserWorkItem ((e) => { DoSomeExpensiveTask(); this.InvokeOnMainThread (() => { DoSomethingInUI(...); }); });
Is there a recommended way to use MonoTouch to create iOS apps?
source share