![]() | ProcessTerminator Class |
Namespace: Neon.Kube.Service
The ProcessTerminator type exposes the following members.
Name | Description | |
---|---|---|
![]() | ProcessTerminator |
Constructor.
|
Name | Description | |
---|---|---|
![]() | CancellationToken |
Returns the CancellationToken that will be cancelled when a
termination signal is received or Exit(Int32) is called explicitly.
|
![]() | CancellationTokenSource |
Returns the CancellationTokenSource that can be used to
cancel any outstanding operations before terminating a process.
|
![]() | DisableProcessExit |
Optionally indicates that the terminator should not actually terminate
the hosting process. This is typically enabled for testing or debugging.
|
![]() | StopEvent |
Returns the AsyncManualResetEvent that will be raised when
the service is being stopped.
|
![]() | TerminateNow |
Returns true when the application has been signalled to terminate.
|
![]() | Timeout |
Returns the termination timeout.
|
Name | Description | |
---|---|---|
![]() | AddDisposable |
Adds a IDisposable instance that will be disposed when the
process is being terminated. This can be a handy way to hook AsyncPeriodicTask
and other components into a ProcessTerminator.
|
![]() | AddHandler |
Adds a termination handler.
|
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Exit |
Cleanly terminates the current process.
|
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | ReadyToExit |
Indicates that the application has gracefully stopped and is
ready to be terminated.
|
![]() | Signal |
Emulates a signal instructing the service to close. This will typically be used
for unit testing services.
|
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
This class listens for a termination signal and then gives the process some time to gracefully save state. The termination timeout defaults to 10 seconds but a custom value may be passed to the constructor.
![]() |
---|
The parent process or operating system typically enforces its own maximum timeout, so your process may still be killed before your timeout is reached. |
This class provides two ways for the application to reach to a termination signal. Programs using the async/await pattern can monitor the CancellationToken returned by the CancellationToken property.
Applications may also use AddHandler(Action) to add one more more methods that will be called when a termination signal is received. Each handler will be called in parallel on its own thread.
Finally, you map pass one or more IDisposable instances to AddDisposable(IDisposable). Dispose will be called for each of these in parallel on its own thread. This can be a handy way of hooking AsyncPeriodicTask instances and other structures into a ProcessTerminator.
Applications should call ReadyToExit when they have gracefully stopped any activities and saved state so that the process will be terminated immediately. Otherwise, the process will be terminated when the parent process' timeout is finally exceeded.
Applications can also call Exit(Int32) to proactively signal that the process should terminate gracefully.