/// <summary> /// <para> /// Handler used to handle new action event from /// <seealso cref="CimSessionProxy"/> object. /// </para> /// </summary> /// <param name="cimSession"> /// <seealso cref="CimSession"/> object raised the event /// </param> /// <param name="actionArgs">Event argument.</param> protected void NewCmdletActionHandler(object cimSession, CmdletActionEventArgs actionArgs) { DebugHelper.WriteLogEx("Disposed {0}, action type = {1}", 0, this.Disposed, actionArgs.Action); if (this.Disposed) { if (actionArgs.Action is CimSyncAction) { // unblock the thread waiting for response (actionArgs.Action as CimSyncAction).OnComplete(); } return; } bool isEmpty = this.actionQueue.IsEmpty; this.actionQueue.Enqueue(actionArgs.Action); if (isEmpty) { this.moreActionEvent.Set(); } }
/// <summary> /// <para> /// Handler used to handle new action event from /// <seealso cref="CimSessionProxy"/> object. /// </para> /// </summary> /// <param name="cimSession"> /// <seealso cref="CimSession"/> object raised the event /// </param> /// <param name="actionArgs">Event argument.</param> private void CimIndicationHandler(object cimSession, CmdletActionEventArgs actionArgs) { DebugHelper.WriteLogEx("action is {0}. Disposed {1}", 0, actionArgs.Action, this.Disposed); if (this.Disposed) { return; } // NOTES: should move after this.Disposed, but need to log the exception CimWriteError cimWriteError = actionArgs.Action as CimWriteError; if (cimWriteError != null) { this.Exception = cimWriteError.Exception; if (!this.ackedEvent.IsSet) { // an exception happened DebugHelper.WriteLogEx("an exception happened", 0); this.ackedEvent.Set(); return; } EventHandler <CimSubscriptionEventArgs> temp = this.OnNewSubscriptionResult; if (temp != null) { DebugHelper.WriteLog("Raise an exception event", 2); temp(this, new CimSubscriptionExceptionEventArgs(this.Exception)); } DebugHelper.WriteLog("Got an exception: {0}", 2, Exception); } CimWriteResultObject cimWriteResultObject = actionArgs.Action as CimWriteResultObject; if (cimWriteResultObject != null) { CimSubscriptionResult result = cimWriteResultObject.Result as CimSubscriptionResult; if (result != null) { EventHandler <CimSubscriptionEventArgs> temp = this.OnNewSubscriptionResult; if (temp != null) { DebugHelper.WriteLog("Raise an result event", 2); temp(this, new CimSubscriptionResultEventArgs(result)); } } else { if (!this.ackedEvent.IsSet) { // an ACK message returned DebugHelper.WriteLogEx("an ack message happened", 0); this.ackedEvent.Set(); return; } else { DebugHelper.WriteLogEx("an ack message should not happen here", 0); } } } }