mirror of
https://github.com/ZuneDev/ZuneShell.dll.git
synced 2026-07-27 13:11:51 -07:00
26 lines
491 B
C#
26 lines
491 B
C#
using CommunityToolkit.Diagnostics;
|
|||
|
|
using System;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
|
||
|
|
namespace Microsoft.Zune;
|
||
|
|
|
||
|
|
public static class AsyncHelper
|
||
|
|
{
|
||
|
|
public static void Run(Task task)
|
||
|
|
{
|
||
|
|
if (task == null)
|
||
|
|
return;
|
||
|
|
|
||
|
|
var t = Task.Run(() => task);
|
||
|
|
t.Wait();
|
||
|
|
}
|
||
|
|
|
||
|
|
public static TResult Run<TResult>(Func<Task<TResult>> action)
|
||
|
|
{
|
||
|
|
Guard.IsNotNull(action);
|
||
|
|
|
||
|
|
var t = Task.Run(action);
|
||
|
|
t.Wait();
|
||
|
|
return t.Result;
|
||
|
|
}
|
||
|
|
}
|