forked from fdorg/flashdevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessHelper.cs
More file actions
92 lines (83 loc) · 2.3 KB
/
Copy pathProcessHelper.cs
File metadata and controls
92 lines (83 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Collections;
using System.Diagnostics;
using System.Threading;
using PluginCore.Managers;
namespace PluginCore.Helpers
{
public class ProcessHelper
{
/// <summary>
/// Starts a basic process asynchronously
/// </summary>
public static void StartAsync(String path)
{
StartDelegate1 dlgt = new StartDelegate1(Start);
dlgt.BeginInvoke(path, null, null);
}
/// <summary>
/// Starts a process with arguments asynchronously
/// </summary>
public static void StartAsync(String path, String arguments)
{
StartDelegate2 dlgt = new StartDelegate2(Start);
dlgt.BeginInvoke(path, arguments, null, null);
}
/// <summary>
/// Starts a process with start info asynchronously
/// </summary>
public static void StartAsync(ProcessStartInfo psi)
{
StartDelegate3 dlgt = new StartDelegate3(Start);
dlgt.BeginInvoke(psi, null, null);
}
/// <summary>
/// Runs a basic process
/// </summary>
private static void Start(String path)
{
try
{
Process.Start(path);
}
catch(Exception ex)
{
TraceManager.AddAsync(ex.Message);
}
}
/// <summary>
/// Runs a process with arguments
/// </summary>
private static void Start(String path, String arguments)
{
try
{
Process.Start(path, arguments);
}
catch (Exception ex)
{
TraceManager.AddAsync(ex.Message);
}
}
/// <summary>
/// Runs a process with start info
/// </summary>
private static void Start(ProcessStartInfo psi)
{
try
{
Process.Start(psi);
}
catch (Exception ex)
{
TraceManager.AddAsync(ex.Message);
}
}
/// <summary>
/// Event delegates of the class
/// </summary>
private delegate void StartDelegate1(String path);
private delegate void StartDelegate2(String path, String arguments);
private delegate void StartDelegate3(ProcessStartInfo psi);
}
}