public override T TryGetNext(out bool success) { switch (_state) { case 1: _enumerator = _source.GetEnumerator(); _state = 2; goto case 2; case 2: while (true) { var item = _enumerator.TryGetNext(out success); if (!success) { break; } if (_predicate(item)) { return(item); } } break; } success = false; return(default(T)); }
private void p_Disposed(object sender, EventArgs e) { FormMain.fActiveWebCams.Remove(new KeyValuePair <string, string>(fUser, MonikerName)); var distributor = Distributor; if (distributor != null) { Distributor = null; ActiveWebCams.Stop(MonikerName); distributor.Dispose(); } var enumerator = fEnumerator; if (enumerator != null) { fEnumerator = null; try { enumerator.Dispose(); } catch { } } base.OnClosed(e); }
public static int SumFastEnumeratorInterface(IFastEnumerator <int> e) { var sum = 0; var x = e.TryMoveNext(out var success); while (success) { sum += x; x = e.TryMoveNext(out success); } return(sum); }
static int VirtualSum(IFastEnumerator <int> e) { var sum = 0; while (true) { var x = e.TryMoveNext(out var success); if (!success) { break; } sum += x; } return(sum); }
public override bool MoveNext() { switch (_state) { case 1: _enumerator = _source.GetEnumerator(); _state = 2; goto case 2; case 2: _current = _enumerator.TryGetNext(out var success); return(success); } return(false); }
private void p_Initialize(string user, string displayName, string monikerName, IFastEnumerator <byte[]> enumerator) { ClientSize = new Size(160, 120); DisplayName = displayName; MonikerName = monikerName; fUser = user; fEnumerator = enumerator; Text = user; FormMain.fActiveWebCams.Add(new KeyValuePair <string, string>(fUser, MonikerName), this); Disposed += p_Disposed; UnlimitedThreadPool.Run(p_Receive); }
public long IFastEnumerator() { IFastEnumerator <int> ife = _array.GetFastEnumerator(); long total = 0; bool remaining = true; ife.Reset(); loop: var i = ife.TryGetNext(out remaining); if (remaining) { total += i; goto loop; } return(total); }
public override R TryGetNext(out bool success) { switch (_state) { case 1: _enumerator = _source.GetEnumerator(); _state = 2; goto case 2; case 2: var item = _enumerator.TryGetNext(out success); if (success) { return(_selector(item)); } break; } success = false; return(default(R)); }
public FormWebCam(string user, string displayName, string monikerName, IFastEnumerator <byte[]> enumerator) { InitializeComponent(); p_Initialize(user, displayName, monikerName, enumerator); }
public Adapter(IFastEnumerator <T> enumerator) { _enumerator = enumerator; Current = default; }