-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
47 lines (41 loc) · 1.16 KB
/
Program.cs
File metadata and controls
47 lines (41 loc) · 1.16 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
namespace WindowsServiceAIFailure
{
using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
/// <summary>Windows service program.</summary>
public static class Program
{
/// <summary>The main entry point for the application.</summary>
public static void Main()
{
LaunchDebugger();
var testService = new TestService();
if (!Environment.UserInteractive)
{
ServiceBase.Run(new ServiceBase[] { testService });
return;
}
testService.PerformFailure();
while (true)
{
Thread.Sleep(TimeSpan.FromSeconds(30));
}
}
/// <summary>Launch the debugger if in debug mode and if it's not currently attached.</summary>
[Conditional("DEBUG")]
private static void LaunchDebugger()
{
if (Environment.UserInteractive)
{
return;
}
if (Debugger.IsAttached)
{
return;
}
Debugger.Launch();
}
}
}