Daniele Bartolini 9 lat temu
rodzic
commit
1fcf7e5806
1 zmienionych plików z 43 dodań i 0 usunięć
  1. 43 0
      tools/core/LocalExec.cs

+ 43 - 0
tools/core/LocalExec.cs

@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012-2016 Daniele Bartolini and individual contributors.
+ * License: https://github.com/taylor001/crown/blob/master/LICENSE
+ */
+
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+using System.Threading;
+using System;
+
+namespace Crown
+{
+	public class LocalExec
+	{
+		public Process _process;
+
+		public LocalExec()
+		{
+			_process = new Process();
+			_process.EnableRaisingEvents = true;
+		}
+
+		public void Close()
+		{
+			if (!_process.HasExited)
+			{
+				_process.Kill();
+				_process.Close();
+			}
+		}
+
+		public void Start(string name, string args, string workdir)
+		{
+			ProcessStartInfo startInfo = new ProcessStartInfo();
+			startInfo.FileName = name;
+			startInfo.Arguments = args;
+			startInfo.WorkingDirectory = workdir;
+
+			_process.StartInfo = startInfo;
+			_process.Start();
+		}
+	}
+}