I am using monotouch/Xamarin for an iOS app.
The documentation for Task.Run
states:
Queues the specified work to run on the
ThreadPool
and returns a task handle for that work.
Which essentially indicates that it could run on any thread ThreadPool
.
I want to do something like:
Task.Run(async () => await PerformTask());
but have it run on the main thread. Normally I would write it using BeginInvokeOnMainThread
as follows:
BeginInvokeOnMainThread(async () => await PerformTask());
But I am doing this in shared code and do not want to use iOS specific calls. Is there a way for me to tell Task.Run() to invoke the action on the main thread?