NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Common.System.SignalHandler Class Reference
Inheritance diagram for Ntp.Common.System.SignalHandler:
Collaboration diagram for Ntp.Common.System.SignalHandler:

Public Member Functions

 SignalHandler (string name, LogBase log)
 
void Start ()
 

Properties

bool Reload [get, private set]
 
bool Stopped [get, private set]
 

Events

EventHandler< EventArgs > ExitApplication
 
- Events inherited from Ntp.Common.App.IApplicationController
EventHandler< EventArgs > ExitApplication
 

Private Member Functions

void Execute ()
 
void RaiseExitApplicationEvent ()
 

Private Attributes

readonly LogBase log
 
readonly string name
 

Detailed Description

Definition at line 29 of file SignalHandler.cs.

Constructor & Destructor Documentation

Ntp.Common.System.SignalHandler.SignalHandler ( string  name,
LogBase  log 
)
inline

Definition at line 31 of file SignalHandler.cs.

32  {
33  this.name = name;
34  this.log = log;
35  Reload = false;
36  Stopped = false;
37  }

Member Function Documentation

void Ntp.Common.System.SignalHandler.Execute ( )
inlineprivate

Definition at line 58 of file SignalHandler.cs.

References e, Ntp.Common.Log.LogFactory.Resume(), Ntp.Common.Log.LogFactory.Suspend(), and Ntp.Common.System.InterProcess.Wait().

59  {
60  bool loop = true;
61 
62  while (loop)
63  {
64  try
65  {
66  switch (InterProcess.Wait(name, log))
67  {
68  case InterProcess.Signal.Exit:
69  loop = false;
70  log.SignalClosing();
72  break;
73  case InterProcess.Signal.Reload:
74  Reload = true;
75  loop = false;
76  log.SignalReloading();
78  break;
79  case InterProcess.Signal.Refresh:
80  var thread = new Thread(() =>
81  {
83  Thread.Sleep(30000);
85  });
86  log.SignalRefreshing();
87  thread.Start();
88  break;
89  case InterProcess.Signal.Notify:
90  break;
91  case InterProcess.Signal.Error:
92  loop = false;
93  log.SignalInterProcError();
95  break;
96  default:
97  log.UnexpectedSignal();
98  break;
99  }
100  }
101  catch (Exception e)
102  {
103  log.SignalHandlerError(e);
104  loop = false;
106  }
107  }
108  }
var e
Definition: bootstrap.min.js:6
static void Resume()
Definition: LogFactory.cs:96

Here is the call graph for this function:

void Ntp.Common.System.SignalHandler.RaiseExitApplicationEvent ( )
inlineprivate

Definition at line 110 of file SignalHandler.cs.

111  {
112  Stopped = true;
113  ExitApplication?.Invoke(this, EventArgs.Empty);
114  }
EventHandler< EventArgs > ExitApplication
void Ntp.Common.System.SignalHandler.Start ( )
inline

Definition at line 48 of file SignalHandler.cs.

49  {
50  // Signal handler is only supported on Unix platforms
51  if (Environment.OSVersion.Platform != PlatformID.Unix)
52  return;
53 
54  var signalHandler = new Thread(Execute);
55  signalHandler.Start();
56  }

Member Data Documentation

readonly LogBase Ntp.Common.System.SignalHandler.log
private

Definition at line 39 of file SignalHandler.cs.

readonly string Ntp.Common.System.SignalHandler.name
private

Definition at line 40 of file SignalHandler.cs.

Property Documentation

bool Ntp.Common.System.SignalHandler.Reload
getprivate set

Definition at line 42 of file SignalHandler.cs.

bool Ntp.Common.System.SignalHandler.Stopped
getprivate set

Definition at line 44 of file SignalHandler.cs.

Event Documentation

EventHandler<EventArgs> Ntp.Common.System.SignalHandler.ExitApplication

Definition at line 46 of file SignalHandler.cs.


The documentation for this class was generated from the following file: