aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/OpenSim.GUI/ProcessManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tools/OpenSim.GUI/ProcessManager.cs')
-rw-r--r--OpenSim/Tools/OpenSim.GUI/ProcessManager.cs71
1 files changed, 71 insertions, 0 deletions
diff --git a/OpenSim/Tools/OpenSim.GUI/ProcessManager.cs b/OpenSim/Tools/OpenSim.GUI/ProcessManager.cs
new file mode 100644
index 0000000..0ab074e
--- /dev/null
+++ b/OpenSim/Tools/OpenSim.GUI/ProcessManager.cs
@@ -0,0 +1,71 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Diagnostics;
5
6namespace OpenSim.GUI
7{
8 public class ProcessManager : Process
9 {
10 private string m_FileName;
11 private string m_Arguments;
12 public ProcessManager(string FileName,string Arguments)
13 {
14 m_FileName = FileName;
15 m_Arguments = Arguments;
16
17// MyProc = new Process();
18 StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
19 Console.WriteLine("WorkingDirectory: " + StartInfo.WorkingDirectory);
20 StartInfo.FileName = m_FileName;
21
22 //p.StartInfo.Arguments = "";
23 StartInfo.UseShellExecute = false;
24 StartInfo.RedirectStandardError = true;
25 StartInfo.RedirectStandardInput = true;
26 StartInfo.RedirectStandardOutput = true;
27 StartInfo.CreateNoWindow = true;
28
29
30
31 }
32
33 public void StartProcess()
34 {
35 try
36 {
37 Start();
38 BeginOutputReadLine();
39 BeginErrorReadLine();
40 }
41 catch (Exception ex)
42 {
43 Console.WriteLine("Exception Occurred :{0},{1}",
44 ex.Message, ex.StackTrace.ToString());
45 }
46 }
47 public void StopProcess()
48 {
49 try
50 {
51 CancelErrorRead();
52 CancelErrorRead();
53 if (!HasExited)
54 {
55 StandardInput.WriteLine("quit");
56 StandardInput.WriteLine("shutdown");
57 System.Threading.Thread.Sleep(500);
58 if (!HasExited)
59 {
60 Kill();
61 }
62 }
63 }
64 catch (Exception ex)
65 {
66 Console.WriteLine("Exception Occurred :{0},{1}",
67 ex.Message, ex.StackTrace.ToString());
68 }
69 }
70 }
71}