public static async ValueTask <ThreadSafeForm <T> > GetAsync(Func <CancellationToken, T> funcFormConstructor, CancellationToken token = default) { return(new ThreadSafeForm <T>(Program.MainForm != null ? await Program.MainForm.DoThreadSafeFuncAsync(funcFormConstructor, token) : await Utils.StartStaTask(() => funcFormConstructor.Invoke(token), token))); }
public static ThreadSafeForm <T> Get(Func <T> funcFormConstructor) { return(new ThreadSafeForm <T>(Program.MainForm != null ? Program.MainForm.DoThreadSafeFunc(funcFormConstructor) : Utils.RunWithoutThreadLock(() => Utils.StartStaTask(funcFormConstructor)))); }