AsyncHelpers Pennington.Infrastructure
Run async code synchronously without deadlocks.
Methods
RunSync
#public static void RunSync(Func<Task> func);Synchronously runs an async delegate on the default task scheduler, bypassing the current synchronization context.
Parameters
funcFunc<Task>
RunSync<TResult>
#public static TResult RunSync<TResult>(Func<Task<TResult>> func);Synchronously runs an async delegate on the default task scheduler and returns its result, bypassing the current synchronization context.
Parameters
funcFunc<Task<TResult>>
Returns
TResultPennington.Infrastructure.AsyncHelpers
namespace Pennington.Infrastructure;
/// Run async code synchronously without deadlocks.
public class AsyncHelpers
{
/// Synchronously runs an async delegate on the default task scheduler, bypassing the current synchronization context.
public static void RunSync(Func<Task> func);
/// Synchronously runs an async delegate on the default task scheduler and returns its result, bypassing the current synchronization context.
public static TResult RunSync<TResult>(Func<Task<TResult>> func);
}