Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
58 lines (51 loc) · 1.59 KB
/
Copy pathProgram.cs
File metadata and controls
58 lines (51 loc) · 1.59 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
/*******************************************************************************************************
* Program.cs
*
* IOCounters.h
*
* http://https://github.com/alonf/JobObjectWrapper
*
* This program is licensed under the MIT License.
*
* Alon Fliess
********************************************************************************************************/
using System;
using System.Threading;
namespace InJobProcessCreator
{
class Program
{
/// <summary>
///
/// </summary>
/// <param name="args">args[0] is the name of the ready event handle, arg[1] is the IPC address (port name), arg[2] is the finish event</param>
/// <returns></returns>
static int Main(string[] args)
{
//System.Diagnostics.Debugger.Break();
try
{
if (args.Length < 3)
return -1;
ProcessActivationService.RegisterRemotingService(args[1]);
SetEvent(args[0]);
WaitForExitEvent(args[2]);
return 0;
}
catch (Exception)
{
return -2;
}
}
private static void WaitForExitEvent(string finishEventName)
{
EventWaitHandle.OpenExisting(finishEventName).WaitOne();
}
private static void SetEvent(string readyEventName)
{
bool bResult = EventWaitHandle.OpenExisting(readyEventName).Set();
if (bResult == false)
throw new Exception("Can't set the ready event");
}
}
}