internal Invocation(Action action, OcDispatcher ocDispatcher, InvocationStatus invocationStatus, object context = null, ManualResetEventSlim doneManualResetEvent = null) : this() { _action = action; _ocDispatcher = ocDispatcher; _context = context; InvocationStatus = invocationStatus; _doneManualResetEvent = doneManualResetEvent; if (Configuration.SaveOcDispatcherInvocationStackTrace) { _callStackTrace = Environment.StackTrace; } }
internal Invocation(Action <object> actionWithState, object state, OcDispatcher ocDispatcher, InvocationStatus invocationStatus, IComputing context = null, ManualResetEventSlim doneManualResetEvent = null) : this() { _actionWithState = actionWithState; _state = state; _ocDispatcher = ocDispatcher; _context = context; InvocationStatus = invocationStatus; _doneManualResetEvent = doneManualResetEvent; if (Configuration.SaveOcDispatcherInvocationStackTrace) { _callStackTrace = Environment.StackTrace; } }
internal void Execute() { Invocation originalCurrentInvocation = _ocDispatcher._currentInvocation; SynchronizationContext originalSynchronizationContext = null; if (_setSynchronizationContext) { originalSynchronizationContext = SynchronizationContext.Current; SynchronizationContext.SetSynchronizationContext( new OcDispatcherSynchronizationContext( _ocDispatcher, _priority, _context, _parent)); } if (OcConfiguration.SaveOcDispatcherInvocationExecutionStackTrace) { _executionStackTrace = Environment.StackTrace; } _executor = originalCurrentInvocation; _ocDispatcher._currentInvocation = this; _status = InvocationStatus.Executing; if (_action != null) { _action(); } else { _actionWithState(_state); } _status = InvocationStatus.Executed; if (_setSynchronizationContext) { SynchronizationContext.SetSynchronizationContext(originalSynchronizationContext); } _ocDispatcher._currentInvocation = originalCurrentInvocation; _doneManualResetEvent?.Set(); }