Represents information about the InvokeCompleted event.
Inheritance: System.EventArgs
        // Raises the InvokeCompleted event.
        private void OnInvokeCompleted(InvokeCompletedEventArgs e)
        {
            EventHandler <InvokeCompletedEventArgs> handler = InvokeCompleted;

            if (handler != null)
            {
                m_context.Post(delegate { handler(this, e); }, null);
            }
        }
Esempio n. 2
0
        // Raises the InvokeCompleted event.
        protected virtual void OnInvokeCompleted(InvokeCompletedEventArgs e)
        {
            EventHandler <InvokeCompletedEventArgs> handler = InvokeCompleted;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 3
0
        // Raises the InvokeCompleted event.
        protected virtual void OnInvokeCompleted(InvokeCompletedEventArgs e)
        {
            EventHandler <InvokeCompletedEventArgs> handler = InvokeCompleted;

            if (handler != null)
            {
                context.Post(delegate(object state)
                {
                    handler(this, e);
                }, null);
            }
        }
Esempio n. 4
0
        private void delegateScheduler1_InvokeCompleted(object sender, InvokeCompletedEventArgs e)
        {
            object[] args = e.GetArgs();

            Debug.Assert(args != null);
            Debug.Assert(args.Length == 1);
            Debug.Assert(args[0] != null);

            if (e.Error == null)
            {
                logListBox.Items.Add(args[0].ToString());
            }
            else
            {
                MessageBox.Show("Error!", e.Error.Message, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Esempio n. 5
0
        // Processes and invokes delegates.
        private void DelegateProcedure()
        {
            lock(lockObject)
            {
                // Signal the constructor that the thread is now running.
                Monitor.Pulse(lockObject);
            }

            // Set this DelegateQueue as the SynchronizationContext for this thread.
            SynchronizationContext.SetSynchronizationContext(this);

            // Placeholder for DelegateQueueAsyncResult objects.
            DelegateQueueAsyncResult result = null;

            // While the DelegateQueue has not been disposed.
            while(true)
            {
                // Critical section.
                lock(lockObject)
                {
                    // If the DelegateQueue has been disposed, break out of loop; we're done.
                    if(disposed)
                    {
                        break;
                    }

                    // If there are delegates waiting to be invoked.
                    if(delegateQueue.Count > 0)
                    {
                        result = delegateQueue.Dequeue();
                    }
                    // Else there are no delegates waiting to be invoked.
                    else
                    {
                        // Wait for next delegate.
                        Monitor.Wait(lockObject);

                        // If the DelegateQueue has been disposed, break out of loop; we're done.
                        if(disposed)
                        {
                            break;
                        }

                        Debug.Assert(delegateQueue.Count > 0);

                        result = delegateQueue.Dequeue();
                    }
                }

                Debug.Assert(result != null);

                // Invoke the delegate.
                result.Invoke();

                if(result.NotificationType == NotificationType.BeginInvokeCompleted)
                {
                    InvokeCompletedEventArgs e = new InvokeCompletedEventArgs(
                        result.Method,
                        result.GetArgs(),
                        result.ReturnValue,
                        result.Error);

                    OnInvokeCompleted(e);
                }
                else if(result.NotificationType == NotificationType.PostCompleted)
                {
                    object[] args = result.GetArgs();

                    Debug.Assert(args.Length == 1);
                    Debug.Assert(result.Method is SendOrPostCallback);

                    PostCompletedEventArgs e = new PostCompletedEventArgs(
                        (SendOrPostCallback)result.Method,
                        args[0],
                        result.Error);

                    OnPostCompleted(e);
                }
                else
                {
                    Debug.Assert(result.NotificationType == NotificationType.None);
                }
            }

            Debug.WriteLine(delegateThread.Name + " Finished");
        }
Esempio n. 6
0
        // Raises the InvokeCompleted event.
        protected virtual void OnInvokeCompleted(InvokeCompletedEventArgs e)
        {
            EventHandler<InvokeCompletedEventArgs> handler = InvokeCompleted;

            if(handler != null)
            {
                context.Post(delegate(object state)
                {
                    handler(this, e);
                }, null);
            }
        }
        // Processes and invokes delegates.
        private void DelegateProcedure()
        {
            lock (m_lockObject)
            {
                // Signal the constructor that the thread is now running.
                Monitor.Pulse(m_lockObject);
            }

            // Set this DelegateQueue as the SynchronizationContext for this thread.
            SetSynchronizationContext(this);

            // Placeholder for DelegateQueueAsyncResult objects.
            DelegateQueueAsyncResult result;

            // While the DelegateQueue has not been disposed.
            while (true)
            {
                // Critical section.
                lock (m_lockObject)
                {
                    // If the DelegateQueue has been disposed, break out of loop; we're done.
                    if (m_disposed)
                    {
                        break;
                    }

                    // If there are delegates waiting to be invoked.
                    if (m_delegateDeque.Count > 0)
                    {
                        result = m_delegateDeque.PopFront();
                    }
                    // Else there are no delegates waiting to be invoked.
                    else
                    {
                        // Wait for next delegate.
                        Monitor.Wait(m_lockObject);

                        // If the DelegateQueue has been disposed, break out of loop; we're done.
                        if (m_disposed)
                        {
                            break;
                        }

                        Debug.Assert(m_delegateDeque.Count > 0);

                        result = m_delegateDeque.PopFront();
                    }
                }

                Debug.Assert(result != null);

                // Invoke the delegate.
                result.Invoke();

                switch (result.NotificationType)
                {
                case NotificationType.BeginInvokeCompleted:
                {
                    InvokeCompletedEventArgs e = new InvokeCompletedEventArgs(
                        result.Method,
                        result.GetArgs(),
                        result.ReturnValue,
                        result.Error);

                    OnInvokeCompleted(e);
                }
                break;

                case NotificationType.PostCompleted:
                {
                    object[] args = result.GetArgs();

                    Debug.Assert(args.Length == 1);
                    Debug.Assert(result.Method is SendOrPostCallback);

                    PostCompletedEventArgs e = new PostCompletedEventArgs(
                        (SendOrPostCallback)result.Method,
                        args[0],
                        result.Error);

                    OnPostCompleted(e);
                }
                break;

                default:
                    Debug.Assert(result.NotificationType == NotificationType.None);
                    break;
                }
            }

            Debug.WriteLine(m_delegateThread.Name + " Finished");
        }
        // Raises the InvokeCompleted event.
        protected virtual void OnInvokeCompleted(InvokeCompletedEventArgs e)
        {
            EventHandler<InvokeCompletedEventArgs> handler = InvokeCompleted;

            if(handler != null)
            {
                handler(this, e);
            }
        }
        // Raises the InvokeCompleted event.
        private void OnInvokeCompleted(InvokeCompletedEventArgs e)
        {
            EventHandler<InvokeCompletedEventArgs> handler = InvokeCompleted;

            if (handler != null)
            {
                m_context.Post(delegate { handler(this, e); }, null);
            }
        }
        // Raises the InvokeCompleted event.
        private void OnInvokeCompleted(InvokeCompletedEventArgs e)
        {
            EventHandler<InvokeCompletedEventArgs> handler = InvokeCompleted;

            if (handler != null)
            {
                handler(this, e);
            }
        }