سؤال

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 . . .

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top