예제 #1
0
        protected internal virtual void Notify <T>(Notifier <T> notifier, T a1, T a2, T a3)
        {
            Cons lners;

            lock (this)
            {
                if (_listeners == DISPATCHING)
                {
                    _pendingRuns = Append(_pendingRuns, new RunsNotifyImpl <T>(this, notifier, a1, a2, a3));
                    return;
                }
                lners = _listeners;
                Cons sentinel = DISPATCHING;
                _listeners = sentinel;
            }
            System.Exception exn = null;
            try
            {
                for (Cons cons = lners; cons != null; cons = cons.next)
                {
                    try
                    {
                        notifier.Notify(cons.Listener(), a1, a2, a3);
                    }
                    catch (System.Exception ex)
                    {
                        JavaSystem.Out.Println(ex.Message);
                        JavaSystem.Out.Println(ex.StackTrace);
                        exn = ex;
                    }
                    if (cons.OneShot())
                    {
                        cons.Close();
                    }
                }
            }
            finally
            {
                lock (this)
                {
                    _listeners = lners;
                }
                Runs run;
                for (; (run = NextRun()) != null;)
                {
                    try
                    {
                        run.Action(this);
                    }
                    catch (System.Exception ex)
                    {
                        exn = ex;
                    }
                }
            }
            if (exn != null)
            {
                throw exn;
            }
        }
예제 #2
0
 protected internal static Cons RemoveAll(Cons head, GoListener listener)
 {
     if (head == null)
     {
         return(null);
     }
     if (head.Listener() == listener)
     {
         return(RemoveAll(head.next, listener));
     }
     head.next = RemoveAll(head.next, listener);
     return(head);
 }