<PackageReference Include="Nito.AsyncEx.Tasks" Version="5.1.1" />

Nito.AsyncEx.TaskHelper

public static class TaskHelper
Helper methods for working with tasks.
public static Task ExecuteAsTask(Action func)

Executes a delegate synchronously, and captures its result in a task. The returned task is already completed.

public static Task<T> ExecuteAsTask<T>(Func<T> func)

Executes a delegate synchronously, and captures its result in a task. The returned task is already completed.