public EnumeratorStructNonAsync(YieldStructDelegateAsync <TStruct> yieldAsync) { yieldAsyncTask = Task.Run(async() => { try { await yieldAsync( (item) => { callbackBarrier.SignalAndWait(); this.Current = item; callbackBarrier.SignalAndWait(); return(Task.FromResult(true)); }); } catch (Exception ex) { exception = ex; throw ex; } finally { complete = true; callbackBarrier.RemoveParticipant(); } }); }
public EnumeratorBlockingStructAsync(YieldStructDelegateAsync <TStruct> yieldAsync) { this.yieldAsync = yieldAsync; var cancelYieldAsyncToken = cancelYieldAsyncTokenSource.Token; yieldAsyncTask = Task.Run(async() => { try { // TODO: Get cancellation token on this thread as well. await yieldAsync( (item) => { callbackBarrier.SignalAndWait(); this.Current = item; callbackBarrier.SignalAndWait(); return(Task.FromResult(true)); }); } catch (Exception ex) { exception = ex; throw ex; } finally { complete = true; callbackBarrier.RemoveParticipant(); } }, cancelYieldAsyncToken); }
public EnumerableStructAsync(YieldStructDelegateAsync <TStruct> yieldAsync) { this.yieldAsync = yieldAsync; }
public static IEnumerableStructAsync <TStruct> YieldStructAsync <TStruct>(YieldStructDelegateAsync <TStruct> yieldAsync) { return(new EnumerableStructAsync <TStruct>(yieldAsync)); }