/// <summary>Invokes MoveNext under the provided context.</summary> internal void Run() { if (m_context != null) { try { // Get the callback, lazily initializing it as necessary Action <object> callback = s_invokeMoveNext; if (callback == null) { s_invokeMoveNext = callback = InvokeMoveNext; } if (m_context == null) { callback(m_stateMachine); } else { // Use the context and callback to invoke m_stateMachine.MoveNext. ExecutionContextLightup.Instance.Run(m_context, callback, m_stateMachine); } } finally { if (m_context != null) { m_context.Dispose(); } } } else { m_stateMachine.MoveNext(); } }
internal void Run() { if (m_context != null) { try { Action <object> action = s_invokeMoveNext; if (action == null) { action = (s_invokeMoveNext = new Action <object>(InvokeMoveNext)); } if (m_context == null) { action.Invoke(m_stateMachine); } else { ExecutionContextLightup.Instance.Run(m_context, action, m_stateMachine); } return; } finally { if (m_context != null) { m_context.Dispose(); } } } m_stateMachine.MoveNext(); }
/// <summary>Invokes <see cref="IAsyncStateMachine.MoveNext"/> under the provided context.</summary> internal void Run() { Debug.Assert(_stateMachine != null, "The state machine must have been set before calling Run."); if (_context != null) { try { // Get the callback, lazily initializing it as necessary Action<object> callback = _invokeMoveNext; if (callback == null) { _invokeMoveNext = callback = InvokeMoveNext; } if (_context == null) { callback(_stateMachine); } else { // Use the context and callback to invoke _stateMachine.MoveNext. ExecutionContextLightup.Instance.Run(_context, callback, _stateMachine); } } finally { if (_context != null) _context.Dispose(); } } else { _stateMachine.MoveNext(); } }