예제 #1
0
        private int InternalSend(int waitTime, IEnumerable <string> identities, string eventName, params string[] arguments)
        {
            int count = 0;

            using (WaitAndContinueList work = new WaitAndContinueList())
            {
                foreach (string identity in Check.NotNull(identities))
                {
                    IpcEventMessage m = new IpcEventMessage(this, ExecutionTimeout, identity, eventName, arguments);
                    if (!m.Completed)
                    {
                        work.AddWork(m);
                    }
                    else
                    {
                        count += m.Successful ? 1 : 0;
                    }
                }

                if (!work.IsEmpty)
                {
                    //Waiting while in-call results in dead-locks, so we force these to defer if they do not complete immediatly
                    if (InCall)
                    {
                        waitTime = 0;
                    }

                    System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
                    if (waitTime > 0)
                    {
                        timer.Start();
                    }

                    IWaitAndContinue waitItem;
                    int ticksRemaining = waitTime;
                    while (work.PerformWork(ticksRemaining, out waitItem))
                    {
                        count += ((IpcEventMessage)waitItem).Successful ? 1 : 0;
                        if (waitTime > 0 && (ticksRemaining = (int)(waitTime - timer.ElapsedMilliseconds)) < 0)
                        {
                            break;
                        }
                    }

                    if (!work.IsEmpty)
                    {
                        WaitAndContinueWorker worker = _deferred;
                        if (worker != null)
                        {
                            try { worker.AddWork(work); } catch (ObjectDisposedException) { }
                        }
                    }
                }
            }
            return(count);
        }
예제 #2
0
 public void CopyHandles(IpcEventMessage msg, WaitHandle[] array, int offset)
 {
 }
예제 #3
0
 public void ContinueProcessing(IpcEventMessage msg, WaitHandle handleSignaled)
 {
 }
예제 #4
0
 public int GetHandleCount(IpcEventMessage msg)
 {
     return(0);
 }