NanoByte.Common  2.10.5
NanoByte.Common.Native.WindowsRestartManager Class Reference

Provides an interface to the Windows Restart Manager. Supported on Windows Vista or newer. More...

Inheritance diagram for NanoByte.Common.Native.WindowsRestartManager:

Public Member Functions

 WindowsRestartManager ()
 Starts a new Restart Manager session. More...
 
void Dispose ()
 Ends the Restart Manager session. More...
 
void RegisterResources (params string[] files)
 Registers resources to the Restart Manager session. The Restart Manager uses the list of resources registered with the session to determine which applications and services must be shut down and restarted. More...
 
string[] ListApps (CancellationToken cancellationToken=default)
 Gets a list of all applications that are currently using resources that have been registered with RegisterResources. More...
 
void ShutdownApps (ITaskHandler handler)
 Initiates the shutdown of applications that are currently using resources that have been registered with RegisterResources. More...
 
void RestartApps (ITaskHandler handler)
 Restarts applications that have been shut down by ShutdownApps and that have been registered to be restarted. More...
 

Detailed Description

Provides an interface to the Windows Restart Manager. Supported on Windows Vista or newer.

See https://msdn.microsoft.com/en-us/library/windows/desktop/cc948910

Constructor & Destructor Documentation

◆ WindowsRestartManager()

NanoByte.Common.Native.WindowsRestartManager.WindowsRestartManager ( )
inline

Starts a new Restart Manager session.

Exceptions
Win32ExceptionThe Restart Manager API returned an error.
PlatformNotSupportedExceptionThe current platform does not support the Restart Manager. Needs Windows Vista or newer.

Member Function Documentation

◆ Dispose()

void NanoByte.Common.Native.WindowsRestartManager.Dispose ( )
inline

Ends the Restart Manager session.

◆ ListApps()

string [] NanoByte.Common.Native.WindowsRestartManager.ListApps ( CancellationToken  cancellationToken = default)
inline

Gets a list of all applications that are currently using resources that have been registered with RegisterResources.

Parameters
cancellationTokenUsed to signal cancellation requests.
Exceptions
IOExceptionThe Restart Manager could not access the registry.
TimeoutExceptionThe Restart Manager could not obtain a Registry write mutex in the allotted time. A system restart is recommended.
Win32ExceptionThe Restart Manager API returned an error.

◆ RegisterResources()

void NanoByte.Common.Native.WindowsRestartManager.RegisterResources ( params string[]  files)
inline

Registers resources to the Restart Manager session. The Restart Manager uses the list of resources registered with the session to determine which applications and services must be shut down and restarted.

Parameters
filesAn array of full filename paths.
Exceptions
Win32ExceptionThe Restart Manager API returned an error.

◆ RestartApps()

void NanoByte.Common.Native.WindowsRestartManager.RestartApps ( ITaskHandler  handler)
inline

Restarts applications that have been shut down by ShutdownApps and that have been registered to be restarted.

Parameters
handlerA callback object used to report progress to the user and allow cancellation.
Exceptions
IOExceptionOne or more applications could not be automatically restarted.
Win32ExceptionThe Restart Manager API returned an error.

◆ ShutdownApps()

void NanoByte.Common.Native.WindowsRestartManager.ShutdownApps ( ITaskHandler  handler)
inline

Initiates the shutdown of applications that are currently using resources that have been registered with RegisterResources.

Parameters
handlerA callback object used to report progress to the user and allow cancellation.
Exceptions
UnauthorizedAccessExceptionOne or more applications could not be shut down. Trying again as administrator may help.
IOExceptionOne or more applications could not be shut down. A system reboot may be required.
Win32ExceptionThe Restart Manager API returned an error.

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