Exemplo n.º 1
0
            public static void DoIt(IObservable <T> observable, Action <T> action)
            {
                Contract.Requires(observable != null);
                Contract.Requires(action != null);

                var me = new SynchronousForEachWorker <T>
                {
                    action = action,
                    mutex  = new AutoResetEvent(false)
                };

                IDisposable disp = observable.Subscribe(me);

                me.mutex.WaitOne();
                if (disp != null)
                {
                    disp.Dispose();
                }
                if (me.exception != null)
                {
                    throw me.exception;
                }
                return;
            }
Exemplo n.º 2
0
 public static void SynchronousForEach <T>(this IObservable <T> source, Action <T> action)
 {
     SynchronousForEachWorker <T> .DoIt(source, action);
 }