コード例 #1
0
        private void FireCallbacks()
        {
            if (bytes.Count == 0)
            {
                FireAllCallbacks();
                return;
            }

            if (callbacks == null)
            {
                return;
            }

            while (callbacks.Count > 0)
            {
                CallbackInfo c = callbacks [0];
                if (c.Index < segments_written)
                {
                    break;
                }
                c.Callback();

                callbacks.RemoveAt(0);
            }
        }
コード例 #2
0
ファイル: EntryPoint.Shared.cs プロジェクト: iainmckay/USharp
        private static unsafe bool Tick(float deltaTime)
        {
            if (lastRuntimeCounter != SharedRuntimeState.Instance->RuntimeCounter)
            {
                if (SharedRuntimeState.IsActiveRuntime || SharedRuntimeState.Instance->IsActiveRuntimeComplete != 0)
                {
                    lastRuntimeCounter = SharedRuntimeState.Instance->RuntimeCounter;
                    Debug.Assert(SharedRuntimeState.Instance->NextRuntime != EDotNetRuntime.None,
                                 "RuntimeCounter changed but NextRuntime is not assigned");
                    OnRuntimeChanged();
                }
                else if (SharedRuntimeState.Instance->NextRuntime == EDotNetRuntime.None)
                {
                    // Runtime swapping likely failed, update our counter
                    lastRuntimeCounter = SharedRuntimeState.Instance->RuntimeCounter;
                }
            }

            lock (callbacks)
            {
                while (callbacks.Count > 0)
                {
                    CallbackInfo callbackInfo = callbacks.Dequeue();
                    callbackInfo.Callback();
                    callbackInfo.WaitHandle.Set();
                }
            }
            return(true);
        }
        private bool ProcessTimer(Guid workflowInstanceId)
        {
            bool         flag  = false;
            CallbackInfo info  = null;
            Guid         empty = Guid.Empty;

            lock (this.locker)
            {
                Guid guid2;
                if (this.HasExpiredTimer(workflowInstanceId, out guid2))
                {
                    info = this.pendingScheduleRequests.Remove(guid2);
                }
            }
            try
            {
                if (info != null)
                {
                    WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "ManualWorkflowSchedulerService: Processing timer {0}", new object[] { empty });
                    info.Callback(info.InstanceId);
                    flag = true;
                }
            }
            catch (Exception exception)
            {
                base.RaiseServicesExceptionNotHandledEvent(exception, workflowInstanceId);
            }
            return(flag);
        }
        private bool ProcessTimer(Guid workflowInstanceId)
        {
            bool         retval  = false;
            CallbackInfo cs      = null;
            Guid         timerId = Guid.Empty;

            lock (locker)
            {
                Guid expTimerId;
                if (HasExpiredTimer(workflowInstanceId, out expTimerId))
                {
                    cs = pendingScheduleRequests.Remove(expTimerId);
                }
            }
            try
            {
                if (cs != null)
                {
                    WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "ManualWorkflowSchedulerService: Processing timer {0}", timerId);
                    cs.Callback(cs.InstanceId);
                    retval = true;
                }
            }
            catch (Exception e)
            {
                RaiseServicesExceptionNotHandledEvent(e, workflowInstanceId);
            }
            return(retval);
        }
        private void OnTimerCallback(object ignored)
        {
            CallbackInfo info = null;

            try
            {
                lock (this.locker)
                {
                    if (base.State.Equals(WorkflowRuntimeServiceState.Started))
                    {
                        info = this.pendingScheduleRequests.Peek();
                        if (info != null)
                        {
                            if (info.IsExpired)
                            {
                                WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "Timeout occured for timer for instance {0}", new object[] { info.InstanceId });
                                this.threadRunning = true;
                                this.pendingScheduleRequests.Dequeue();
                            }
                            else
                            {
                                this.callbackTimer = this.CreateTimerCallback(info);
                            }
                        }
                    }
                }
                if (this.threadRunning)
                {
                    info.Callback(info.InstanceId);
                    this.RunWorkflow(info.InstanceId);
                }
            }
            catch (ThreadAbortException exception)
            {
                WorkflowTrace.Host.TraceEvent(TraceEventType.Error, 0, "Timeout for instance, {0} threw exception {1}", new object[] { (info == null) ? Guid.Empty : info.InstanceId, exception.Message });
                base.RaiseServicesExceptionNotHandledEvent(exception, info.InstanceId);
                throw;
            }
            catch (Exception exception2)
            {
                WorkflowTrace.Host.TraceEvent(TraceEventType.Error, 0, "Timeout for instance, {0} threw exception {1}", new object[] { (info == null) ? Guid.Empty : info.InstanceId, exception2.Message });
                base.RaiseServicesExceptionNotHandledEvent(exception2, info.InstanceId);
            }
            finally
            {
                lock (this.locker)
                {
                    if (this.threadRunning)
                    {
                        this.threadRunning = false;
                        info = this.pendingScheduleRequests.Peek();
                        if (info != null)
                        {
                            this.callbackTimer = this.CreateTimerCallback(info);
                        }
                    }
                }
            }
        }
        private void OnTimerCallback(object ignored)
        {
            CallbackInfo ci = null;

            try
            {
                lock (locker)
                {
                    if (State.Equals(WorkflowRuntimeServiceState.Started))
                    {
                        ci = pendingScheduleRequests.Peek();
                        if (ci != null)
                        {
                            if (ci.IsExpired)
                            {
                                WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "Timeout occured for timer for instance {0}", ci.InstanceId);
                                threadRunning = true;
                                pendingScheduleRequests.Dequeue();
                            }
                            else
                            {
                                callbackTimer = CreateTimerCallback(ci);
                            }
                        }
                    }
                }
                if (threadRunning)
                {
                    ci.Callback(ci.InstanceId);  // delivers the timer message
                    RunWorkflow(ci.InstanceId);
                }
            }
            catch (ThreadAbortException e)
            {
                WorkflowTrace.Host.TraceEvent(TraceEventType.Error, 0, "Timeout for instance, {0} threw exception {1}", ci == null ? Guid.Empty : ci.InstanceId, e.Message);
                RaiseServicesExceptionNotHandledEvent(e, ci.InstanceId);
                throw;
            }
            catch (Exception e)
            {
                WorkflowTrace.Host.TraceEvent(TraceEventType.Error, 0, "Timeout for instance, {0} threw exception {1}", ci == null ? Guid.Empty : ci.InstanceId, e.Message);
                RaiseServicesExceptionNotHandledEvent(e, ci.InstanceId);
            }
            finally
            {
                lock (locker)
                {
                    if (threadRunning)
                    {
                        threadRunning = false;
                        ci            = pendingScheduleRequests.Peek();
                        if (ci != null)
                        {
                            callbackTimer = CreateTimerCallback(ci);
                        }
                    }
                }
            }
        }
コード例 #7
0
        private void OnTimerCallback(object ignored)
        {
            //Make sure activity ID comes out of Threadpool are initialized to null.
            Trace.CorrelationManager.ActivityId = Guid.Empty;

            CallbackInfo ci   = null;
            bool         fire = false;

            try
            {
                lock (timerQueue)
                {
                    if (State == WorkflowRuntimeServiceState.Started)
                    {
                        ci = timerQueue.Peek();
                        if (ci != null)
                        {
                            if (ci.IsExpired)
                            {
                                WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "Timeout occured for timer for instance {0}", ci.State);
                                timerQueue.Dequeue();
                                fire = true;
                            }
                            else
                            {
                                callbackTimer = CreateTimerCallback(ci);
                            }
                        }
                    }
                }
                if (fire && ci != null)
                {
                    ci.Callback(ci.State);
                }
            }
            // Ignore cases where the workflow has been stolen out from under us
            catch (WorkflowOwnershipException)
            { }
            catch (ThreadAbortException e)
            {
                WorkflowTrace.Host.TraceEvent(TraceEventType.Error, 0, "Timeout for instance, {0} threw exception {1}", ci == null ? null : ci.State, e.Message);
                RaiseServicesExceptionNotHandledEvent(e, (Guid)ci.State);
                throw;
            }
            catch (Exception e)
            {
                WorkflowTrace.Host.TraceEvent(TraceEventType.Error, 0, "Timeout for instance, {0} threw exception {1}", ci == null ? null : ci.State, e.Message);
                RaiseServicesExceptionNotHandledEvent(e, (Guid)ci.State);
            }
        }
コード例 #8
0
        private void OnTimerCallback(object ignored)
        {
            Trace.CorrelationManager.ActivityId = Guid.Empty;
            CallbackInfo info = null;
            bool         flag = false;

            try
            {
                lock (this.timerQueue)
                {
                    if (base.State == WorkflowRuntimeServiceState.Started)
                    {
                        info = this.timerQueue.Peek();
                        if (info != null)
                        {
                            if (info.IsExpired)
                            {
                                WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "Timeout occured for timer for instance {0}", new object[] { info.State });
                                this.timerQueue.Dequeue();
                                flag = true;
                            }
                            else
                            {
                                this.callbackTimer = this.CreateTimerCallback(info);
                            }
                        }
                    }
                }
                if (flag && (info != null))
                {
                    info.Callback(info.State);
                }
            }
            catch (WorkflowOwnershipException)
            {
            }
            catch (ThreadAbortException exception)
            {
                WorkflowTrace.Host.TraceEvent(TraceEventType.Error, 0, "Timeout for instance, {0} threw exception {1}", new object[] { (info == null) ? null : info.State, exception.Message });
                base.RaiseServicesExceptionNotHandledEvent(exception, (Guid)info.State);
                throw;
            }
            catch (Exception exception2)
            {
                WorkflowTrace.Host.TraceEvent(TraceEventType.Error, 0, "Timeout for instance, {0} threw exception {1}", new object[] { (info == null) ? null : info.State, exception2.Message });
                base.RaiseServicesExceptionNotHandledEvent(exception2, (Guid)info.State);
            }
        }