Пример #1
0
            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));
            }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
            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);
            }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
            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));
            }
Пример #9
0
        public FormWebCam(string user, string displayName, string monikerName, IFastEnumerator <byte[]> enumerator)
        {
            InitializeComponent();

            p_Initialize(user, displayName, monikerName, enumerator);
        }
Пример #10
0
 public Adapter(IFastEnumerator <T> enumerator)
 {
     _enumerator = enumerator;
     Current     = default;
 }