本文整理汇总了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)));
}