public static IAsyncResult RunAsync <T>(Func <IAsyncExecutor, IEnumerator <int> > action, T state, Action <T> complete) { AsyncExecutor executor = new AsyncExecutor(); AsyncCallback callback = x => { executor.EndExecute(x); complete(state); }; return(executor.BeginExecute(action(executor), callback, state)); }
public static void Run(Func <IAsyncExecutor, IEnumerator <int> > action) { AsyncExecutor executor = new AsyncExecutor(); executor.Execute(action(executor)); }