Pergunta

I was wondering if there's a cleaner work-around for this:

public class Sys
{
    public static void DispatchAsync(Action action)
    {
        DispatchQueue.MainQueue.DispatchAsync(() => { action(); });
    }
}

This Sys class is platform-neutral, so Action should be the method parameter type, but GCD's DispatchAsync won't take action if it's an Action type, only as an NSAction or the work-around here . . .

Foi útil?

Solução

The class Sysisn't platform neutral if it is using Grand Central Dispatch. Better use Task.Run() and async/await.

And no, there is no better way than your workaround.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top