This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

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