This site provides a machine-readable index at /llms.txt.

Skip to main content Skip to navigation

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

func Func<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

func Func<Task<TResult>>

Returns

TResult

Pennington.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);
}