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


C# Process.InitializeLifetimeService方法代码示例

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


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

示例1: Run

        public void Run()
        {
            dirPath = Environment.CurrentDirectory + "/Images/";
            if (!Directory.Exists(dirPath))
                dirPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "/Images/";

            DateTime startTime = DateTime.Now;
            Console.WriteLine(string.Format("Get image from camera: {0}", startTime));

            // find the raspistill process
            foreach (Process p in Process.GetProcessesByName("raspistill"))
                raspistillProcess = p;

            // start the process
            if (raspistillProcess == null)
            {
                string shellExecCmd = "raspistill";
                string shellExecParams = "-t 0 -s -o camera_pic.jpg";
                //string shellExecParams = "-t 0 -s -o camera_pic.jpg &";
                //string shellExecParams = "-n -t 0 -h " + imageSize.Height
                //    + " -w " + imageSize.Width + " -q 100 -o " + dirPath + "camera-pic.jpg";

                Console.WriteLine(string.Format("Starting process: {0} {1}", shellExecCmd, shellExecParams));

                raspistillProcess = Process.Start(
                    new ProcessStartInfo(shellExecCmd, shellExecParams) {
                        RedirectStandardError = false,
                        UseShellExecute = true
                    }
                );

                raspistillProcess.InitializeLifetimeService();

                // add some thread sleep to allow the process to be created
                System.Threading.Thread.Sleep(500);
            }

            // send process command to take the image
            Console.WriteLine(string.Format("Send process command: kill -SIGUSR1 {0}", raspistillProcess.Id));
            Process.Start(
                new ProcessStartInfo("kill", string.Format("{0} {1}", "-SIGUSR1 ", raspistillProcess.Id))
            );

            Console.WriteLine(string.Format("Duration: {0} sec", (DateTime.Now - startTime)));
        }
开发者ID:strofos,项目名称:grigore,代码行数:45,代码来源:Camera.cs


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