The C# async await feature is not yet available in MonoTouch 6.0. Until then what is the best way to implement an async task in MonoTouch.
The MonoTouch docs recommend Threading from the System.Threading namespace to create responsive UI. But once the background worker thread is going how do I cancel it if it takes a long time? Do I need to implement a timer say for 60 secs and kill the thread when the timer event fires?
Are there better options?
Any help highly appreciated
Thanks
I’m not sure how much Mono has of the CLR at this point, but for background tasks, here’s my list, most-recommended first (full details on the rankings can be found on my blog):
TaskBackgroundWorkerDelegate.BeginInvokeThreadPool.QueueUserWorkItemThreadFor a “cancellation flag”, I’d recommend one of these:
CancellationToken– the gold standard. Use this if it’s available.ManualResetEventvolatile boolCancellation is cooperative by nature, so the canceling side sends a cancellation notification, and the receiving side must periodically check it.