Exemplo n.º 1
0
        private void ElapsedThreadProc()
        {
            while (true)
            {
                m_waitHandle.WaitOne();

                if (m_disposing)
                {
                    return;
                }

                ElapsedEventArgs eea = new ElapsedEventArgs(DateTime.Now);

                if (Elapsed != null)
                {
                    foreach (ElapsedEventHandler eeh in Elapsed.GetInvocationList())
                    {
                        // determine if we're supposed to Invoke or not
                        if (SynchronizingObject == null)
                        {
                            eeh(this, eea);
                        }
                        else
                        {
                            SynchronizingObject.Invoke(eeh, new object[] { this, eea });
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 // this hides the parameter ugliness from the managed caller
 private void TimerCallbackShim(uint uTimerID, uint uMsg, ref uint dwUser, ref uint dw1, ref uint dw2)
 {
     if (this.SynchronizingObject != null)
     {
         SynchronizingObject.Invoke(new CallbackHandler(TimerCallback));
     }
     else
     {
         TimerCallback();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Executes an event that occurs inside the running method pump.
 /// </summary>
 /// <remarks>Call the DoEvent to execute an event on the correct thread.
 /// This method checks if SinchronizingObject property is set and executes
 /// the event using the ISynchronizeInvoke interface.  By doing so this
 /// insures that the event is fired only when the thread is in a valid state.</remarks>
 protected virtual void DoEvent(Delegate anEvent, bool asynchronous, params object[] args)
 {
     if (SynchronizingObject == null)
     {
         anEvent.DynamicInvoke(args);
     }
     else if (asynchronous)
     {
         SynchronizingObject.BeginInvoke(anEvent, args);
     }
     else
     {
         SynchronizingObject.Invoke(anEvent, args);
     }
 }
Exemplo n.º 4
0
        internal void FixedErrorReadNotifyUser(string data)
        {
            DataReceivedEventHandler errorDataReceived = ErrorDataReceived;

            if (errorDataReceived != null)
            {
                DataReceivedEventArgs dataReceivedEventArgs = new DataReceivedEventArgs(data);
                if (SynchronizingObject != null && SynchronizingObject.InvokeRequired)
                {
                    SynchronizingObject.Invoke(errorDataReceived, new object[]
                    {
                        this,
                        dataReceivedEventArgs
                    });
                    return;
                }
                errorDataReceived(this, dataReceivedEventArgs);
            }
        }