Exemplo n.º 1
0
        /// <summary>
        /// Creates a {@code WaitDispatchSupport} instance to
        /// serve the given event dispatch thread.
        /// </summary>
        /// <param name="dispatchThread"> An event dispatch thread that
        ///        should not stop dispatching events while waiting </param>
        /// <param name="extCond"> A conditional object used to determine
        ///        if the loop should be terminated
        ///
        /// @since 1.7 </param>
        public WaitDispatchSupport(EventDispatchThread dispatchThread, Conditional extCond)
        {
            if (dispatchThread == null)
            {
                throw new IllegalArgumentException("The dispatchThread can not be null");
            }

            this.DispatchThread = dispatchThread;
            this.ExtCondition   = extCond;
            this.Condition      = new ConditionalAnonymousInnerClassHelper(this);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a {@code WaitDispatchSupport} instance to
 /// serve the given event dispatch thread.
 /// <para>
 /// The <seealso cref="EventFilter"/> is set on the {@code dispatchThread}
 /// while waiting. The filter is removed on completion of the
 /// waiting process.
 /// </para>
 /// <para>
 ///
 ///
 /// </para>
 /// </summary>
 /// <param name="dispatchThread"> An event dispatch thread that
 ///        should not stop dispatching events while waiting </param>
 /// <param name="filter"> {@code EventFilter} to be set </param>
 /// <param name="interval"> A time interval to wait for. Note that
 ///        when the waiting process takes place on EDT
 ///        there is no guarantee to stop it in the given time
 ///
 /// @since 1.7 </param>
 public WaitDispatchSupport(EventDispatchThread dispatchThread, Conditional extCondition, EventFilter filter, long interval) : this(dispatchThread, extCondition)
 {
     this.Filter = filter;
     if (interval < 0)
     {
         throw new IllegalArgumentException("The interval value must be >= 0");
     }
     this.Interval = interval;
     if (interval != 0)
     {
         InitializeTimer();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Dispatches the nested event after all previous nested events have been
        /// dispatched or disposed. If this method is invoked before all previous nested events
        /// have been dispatched, then this method blocks until such a point is
        /// reached.
        /// While waiting disposes nested events to disposed AppContext
        ///
        /// NOTE: Locking protocol.  Since dispose() can get EventQueue lock,
        /// dispatch() shall never call dispose() while holding the lock on the list,
        /// as EventQueue lock is held during dispatching.  The locks should be acquired
        /// in the same order.
        /// </summary>
        public void Dispatch()
        {
            try
            {
                AppContext = AppContext.AppContext;

                if (First != this)
                {
                    if (EventQueue.DispatchThread)
                    {
                        EventDispatchThread edt = (EventDispatchThread)Thread.CurrentThread;
                        edt.PumpEvents(SentEvent.ID, new ConditionalAnonymousInnerClassHelper(this));
                    }
                    else
                    {
                        while (!FirstOrDisposed)
                        {
                            lock (typeof(SequencedEvent))
                            {
                                try
                                {
                                    Monitor.Wait(typeof(SequencedEvent), TimeSpan.FromMilliseconds(1000));
                                }
                                catch (InterruptedException)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }

                if (!Disposed)
                {
                    KeyboardFocusManager.CurrentKeyboardFocusManager.CurrentSequencedEvent = this;
                    Toolkit.EventQueue.DispatchEvent(Nested);
                }
            }
            finally
            {
                Dispose();
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a {@code WaitDispatchSupport} instance to
 /// serve the given event dispatch thread.
 /// </summary>
 /// <param name="dispatchThread"> An event dispatch thread that
 ///        should not stop dispatching events while waiting
 ///
 /// @since 1.7 </param>
 public WaitDispatchSupport(EventDispatchThread dispatchThread) : this(dispatchThread, null)
 {
 }
Exemplo n.º 5
0
 public ConditionalAnonymousInnerClassHelper(EventDispatchThread outerInstance)
 {
     this.OuterInstance = outerInstance;
 }