当前位置: 首页>>代码示例>>C#>>正文


C# Process.SetLogger方法代码示例

本文整理汇总了C#中System.Diagnostics.Process.SetLogger方法的典型用法代码示例。如果您正苦于以下问题:C# Process.SetLogger方法的具体用法?C# Process.SetLogger怎么用?C# Process.SetLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.Process的用法示例。


在下文中一共展示了Process.SetLogger方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: runScript

 private void runScript(string message)
 {
     if (_isFaulted)
         return;
     var originalMessage = message;
     message = "{event} {global-profile} {local-profile}";
     Logger.Write("Running: " + _file + " " + message);
     ThreadPool.QueueUserWorkItem((task) => {
         try
         {
             var process = new Process();
             var responseDispatcher = new ResponseDispatcher(
                 _keyPath,
                 _dispatchErrors,
                 "rscript-" + Name + " ",
                 _outputDispatcher,
                 internalDispatch,
                 (response) => process.Write(response)
             );
             process.SetLogger((logMsg) => Logger.Write(logMsg));
             var msg = task.ToString();
             process.Query(
                 _file,
                 msg,
                 false,
                 _keyPath,
                 (error, m) => {
                     if (m == null)
                         return;
                     Logger.Write("request doing " + m);
                     if (error) {
                         Logger.Write("rscript-" + Name + " produced an error:");
                         Logger.Write("rscript-" + Name + "-" + m);
                     }
                     responseDispatcher.Handle(error, m);
                 },
                 new[] {
                     new KeyValuePair<string,string>("{event}", "\"" + originalMessage + "\""),
                     new KeyValuePair<string,string>("{global-profile}", "\"" + _globalProfileName + "\""),
                     new KeyValuePair<string,string>("{local-profile}", "\"" + _localProfileName + "\"")
                 });
             Logger.Write("RScript completed");
         }
         catch (Exception ex)
         {
             internalDispatch("rscript-" + Name + " " + ex.ToString());
             Logger.Write(ex.ToString());
         }
     }, message);
 }
开发者ID:continuoustests,项目名称:OpenIDE,代码行数:50,代码来源:ReactiveScript.cs

示例2: startService

 private void startService()
 {
     _service = new Process();
     try
     {
         var responseDispatcher = new ResponseDispatcher(
             _keyPath,
             _dispatchErrors,
             "rscript-" + Name + " ",
             _outputDispatcher,
             internalDispatch,
             (response) => _service.Write(response)
         );
         _service.SetLogger((logMsg) => Logger.Write(logMsg));
         _service.Query(
             _file,
             "{global-profile} {local-profile}",
             false,
             _keyPath,
             (error, m) => {
                 if (m == null)
                     return;
                 Logger.Write("request doing " + m);
                 if (error) {
                     Logger.Write("rscript-" + Name + " produced an error:");
                     Logger.Write("rscript-" + Name + "-" + m);
                 }
                 responseDispatcher.Handle(error, m);
             },
             new[] {
                 new KeyValuePair<string,string>("{global-profile}", "\"" + _globalProfileName + "\""),
                 new KeyValuePair<string,string>("{local-profile}", "\"" + _localProfileName + "\"")
             });
         Logger.Write("Exiting service script");
     }
     catch (Exception ex)
     {
         internalDispatch("rscript-" + Name + " " + ex.ToString());
         Logger.Write(ex.ToString());
     }
 }
开发者ID:continuoustests,项目名称:OpenIDE,代码行数:41,代码来源:ReactiveScript.cs

示例3: Run

 public void Run(string message)
 {
     if (Environment.OSVersion.Platform != PlatformID.Unix &&
         Environment.OSVersion.Platform != PlatformID.MacOSX)
     {
         message = message
                     .Replace(" ", "^ ")
                     .Replace("|", "^|")
                     .Replace("%", "^&")
                     .Replace("&", "^&")
                     .Replace("<", "^<")
                     .Replace(">", "^>");
     }
     var originalMessage = message;
     message = "{event} {global-profile} {local-profile}";
     Logger.Write("Running: " + _file + " " + message);
     ThreadPool.QueueUserWorkItem((task) => {
         try
         {
             var process = new Process();
             process.SetLogger((logMsg) => Logger.Write(logMsg));
             var msg = task.ToString();
             process.Query(
                 _file,
                 msg,
                 false,
                 _keyPath,
                 (error, m) => {
                     if (m == null)
                         return;
                     var cmdText = "command|";
                     var eventText = "event|";
                     if (error) {
                         Logger.Write("rscript-" + Name + " produced an error:");
                         Logger.Write("rscript-" + Name + "-" + m);
                     } else {
                         if (m.StartsWith(cmdText))
                             _dispatch(m.Substring(cmdText.Length, m.Length - cmdText.Length));
                         else if (m.StartsWith(eventText))
                             _dispatch(m.Substring(eventText.Length, m.Length - eventText.Length));
                         else
                             _dispatch("rscript-" + Name + " " + m);
                     }
                 },
                 new[] {
                     new KeyValuePair<string,string>("{event}", "\"" + originalMessage + "\""),
                     new KeyValuePair<string,string>("{global-profile}", "\"" + _globalProfileName + "\""),
                     new KeyValuePair<string,string>("{local-profile}", "\"" + _localProfileName + "\"")
                 });
         }
         catch (Exception ex)
         {
             Logger.Write(ex.ToString());
         }
     }, message);
 }
开发者ID:acken,项目名称:OpenIDE,代码行数:56,代码来源:ReactiveScript.cs


注:本文中的System.Diagnostics.Process.SetLogger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。