PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.Async Class Reference

Provides methods to run async code synchronously and safely http://stackoverflow.com/questions/5095183/how-would-i-run-an-async-taskt-method-synchronously. More...

Static Public Member Functions

static void RunSync (Func< Task > task)
 Executes an async Action synchronously.
static T RunSync< T > (Func< Task< T > > task)
 Executes an async Func<T> synchronously and returns the result.

Detailed Description

Member Function Documentation

◆ RunSync()

void PeanutButter.Utils.Async.RunSync ( Func< Task > task)
static

Executes an async Action synchronously.

  • use when you really cannot use async/await
  • NEVER use Task.Wait() or Task.Result if the underlying code uses async/await
Parameters
taskAction to execute

◆ RunSync< T >()

T PeanutButter.Utils.Async.RunSync< T > ( Func< Task< T > > task)
static

Executes an async Func<T> synchronously and returns the result.

  • use when you really cannot use async/await
  • NEVER use Task.Wait() or Task.Result if the underlying code uses async/await
Template Parameters
TReturn Type
Parameters
taskTask<T> method to execute
Returns

The documentation for this class was generated from the following file:
  • source/Utils/PeanutButter.Utils/Async.cs