public void OnCmdOutput(string strCmdInfo) { if (OutputCmdInfoCallBack != null) { Delegate[] invokeList = OutputCmdInfoCallBack.GetInvocationList(); IEnumerator ie = invokeList.GetEnumerator(); while (ie.MoveNext()) { OutputCmdInfoHandler outputCmdInfo = ie.Current as OutputCmdInfoHandler; try { outputCmdInfo.Invoke(strCmdInfo); } catch (Exception) { OutputCmdInfoCallBack -= outputCmdInfo; } } } }
void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e) { string strErrorLine = e.Data; // Invoke the output handlers if (m_outputCmdInfoHandlers != null) { Delegate[] invokeList = m_outputCmdInfoHandlers.GetInvocationList(); IEnumerator ie = invokeList.GetEnumerator(); while (ie.MoveNext()) { OutputCmdInfoHandler outputCmdInfo = ie.Current as OutputCmdInfoHandler; try { outputCmdInfo.Invoke(strErrorLine); } catch (Exception) { // m_outputCmdInfoHandlers -= outputCmdInfo; } } } }
void Process_OutputDataReceived(object sender, DataReceivedEventArgs e) { m_iOutputLineCount++; // Neglect the first 4 lines // "Microsft copyright. // xxxxx // <blank line> // c:\><command>" if (m_iOutputLineCount > 4) { string strOutputLine = e.Data; // We output the privious line instead of current one, because we need to strip the last line which is the current directory if (strOutputLine != null) { // Invoke the output handlers if (m_outputCmdInfoHandlers != null) { Delegate[] invokeList = m_outputCmdInfoHandlers.GetInvocationList(); IEnumerator ie = invokeList.GetEnumerator(); while (ie.MoveNext()) { OutputCmdInfoHandler outputCmdInfo = ie.Current as OutputCmdInfoHandler; try { outputCmdInfo.Invoke(m_strLastOutputLine); } catch (Exception) { // m_outputCmdInfoHandlers -= outputCmdInfo; } } } m_strLastOutputLine = strOutputLine; } } }
public int AddCmdOutputEventSinker(OutputCmdInfoHandler outputCmdInfo) { m_outputCmdInfoHandlers += outputCmdInfo; return(0); }