mirror of
https://github.com/ZuneDev/ZuneShell.dll.git
synced 2026-07-27 13:11:51 -07:00
27 lines
536 B
C#
27 lines
536 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) => Run(action());
|
|
|
|
public static TResult Run<TResult>(Task<TResult> task)
|
|
{
|
|
Guard.IsNotNull(task);
|
|
|
|
return task.GetAwaiter().GetResult();
|
|
}
|
|
}
|