Class WindowsRestartManager
Provides an interface to the Windows Restart Manager. Supported on Windows Vista or newer.
Namespace: NanoByte.Common.Native
Assembly: NanoByte.Common.dll
Syntax
public sealed class WindowsRestartManager : MarshalByRefObject
Remarks
Constructors
WindowsRestartManager()
Starts a new Restart Manager session.
Declaration
public WindowsRestartManager()
Exceptions
Type | Condition |
---|---|
Win32Exception | The Restart Manager API returned an error. |
PlatformNotSupportedException | The current platform does not support the Restart Manager. Needs Windows Vista or newer. |
DllNotFoundException | The Restart Manager API is missing. |
Methods
Dispose()
Ends the Restart Manager session.
Declaration
public void Dispose()
Finalize()
Declaration
protected override void Finalize()
ListApps(CancellationToken)
Gets a list of all applications that are currently using resources that have been registered with RegisterResources(String[]).
Declaration
public string[] ListApps(CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Used to signal cancellation requests. |
Returns
Type | Description |
---|---|
String[] |
Exceptions
Type | Condition |
---|---|
IOException | The Restart Manager could not access the registry. |
TimeoutException | The Restart Manager could not obtain a Registry write mutex in the allotted time. A system restart is recommended. |
Win32Exception | The Restart Manager API returned an error. |
RegisterResources(String[])
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.
Declaration
public void RegisterResources(params string[] files)
Parameters
Type | Name | Description |
---|---|---|
String[] | files | An array of full filename paths. |
Exceptions
Type | Condition |
---|---|
Win32Exception | The Restart Manager API returned an error. |
RestartApps(ITaskHandler)
Restarts applications that have been shut down by ShutdownApps(ITaskHandler) and that have been registered to be restarted.
Declaration
public void RestartApps(ITaskHandler handler)
Parameters
Type | Name | Description |
---|---|---|
ITaskHandler | handler | A callback object used to report progress to the user and allow cancellation. |
Exceptions
Type | Condition |
---|---|
IOException | One or more applications could not be automatically restarted. |
Win32Exception | The Restart Manager API returned an error. |
ShutdownApps(ITaskHandler)
Initiates the shutdown of applications that are currently using resources that have been registered with RegisterResources(String[]).
Declaration
public void ShutdownApps(ITaskHandler handler)
Parameters
Type | Name | Description |
---|---|---|
ITaskHandler | handler | A callback object used to report progress to the user and allow cancellation. |
Exceptions
Type | Condition |
---|---|
UnauthorizedAccessException | One or more applications could not be shut down. Trying again as administrator may help. |
IOException | One or more applications could not be shut down. A system reboot may be required. |
Win32Exception | The Restart Manager API returned an error. |