Class WindowsRestartManager
Provides an interface to the Windows Restart Manager. Supported on Windows Vista or newer.
public sealed class WindowsRestartManager : MarshalByRefObject
- Inheritance
-
objectMarshalByRefObjectWindowsRestartManager
- Extension Methods
Remarks
Constructors
WindowsRestartManager()
Starts a new Restart Manager session.
public WindowsRestartManager()
Exceptions
- 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.
public void Dispose()
~WindowsRestartManager()
protected ~WindowsRestartManager()
ListApps(CancellationToken)
Gets a list of all applications that are currently using resources that have been registered with RegisterResources(params string[]).
public string[] ListApps(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenUsed to signal cancellation requests.
Returns
- string[]
Exceptions
- 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(params 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.
public void RegisterResources(params string[] files)
Parameters
files
string[]An array of full filename paths.
Exceptions
- 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.
public void RestartApps(ITaskHandler handler)
Parameters
handler
ITaskHandlerA callback object used to report progress to the user and allow cancellation.
Exceptions
- 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(params string[]).
public void ShutdownApps(ITaskHandler handler)
Parameters
handler
ITaskHandlerA callback object used to report progress to the user and allow cancellation.
Exceptions
- 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.