aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common')
-rw-r--r--MediaBrowser.Common/Extensions/ProcessExtensions.cs60
-rw-r--r--MediaBrowser.Common/IApplicationHost.cs21
-rw-r--r--MediaBrowser.Common/Plugins/IPluginManager.cs5
3 files changed, 8 insertions, 78 deletions
diff --git a/MediaBrowser.Common/Extensions/ProcessExtensions.cs b/MediaBrowser.Common/Extensions/ProcessExtensions.cs
index c3a7cb394..bb8ab130d 100644
--- a/MediaBrowser.Common/Extensions/ProcessExtensions.cs
+++ b/MediaBrowser.Common/Extensions/ProcessExtensions.cs
@@ -15,65 +15,13 @@ namespace MediaBrowser.Common.Extensions
/// </summary>
/// <param name="process">The process to wait for.</param>
/// <param name="timeout">The duration to wait before cancelling waiting for the task.</param>
- /// <returns>True if the task exited normally, false if the timeout elapsed before the process exited.</returns>
- /// <exception cref="InvalidOperationException">If <see cref="Process.EnableRaisingEvents"/> is not set to true for the process.</exception>
- public static async Task<bool> WaitForExitAsync(this Process process, TimeSpan timeout)
+ /// <returns>A task that will complete when the process has exited, cancellation has been requested, or an error occurs.</returns>
+ /// <exception cref="OperationCanceledException">The timeout ended.</exception>
+ public static async Task WaitForExitAsync(this Process process, TimeSpan timeout)
{
using (var cancelTokenSource = new CancellationTokenSource(timeout))
{
- return await WaitForExitAsync(process, cancelTokenSource.Token).ConfigureAwait(false);
- }
- }
-
- /// <summary>
- /// Asynchronously wait for the process to exit.
- /// </summary>
- /// <param name="process">The process to wait for.</param>
- /// <param name="cancelToken">A <see cref="CancellationToken"/> to observe while waiting for the process to exit.</param>
- /// <returns>True if the task exited normally, false if cancelled before the process exited.</returns>
- public static async Task<bool> WaitForExitAsync(this Process process, CancellationToken cancelToken)
- {
- if (!process.EnableRaisingEvents)
- {
- throw new InvalidOperationException("EnableRisingEvents must be enabled to async wait for a task to exit.");
- }
-
- // Add an event handler for the process exit event
- var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
- process.Exited += (_, _) => tcs.TrySetResult(true);
-
- // Return immediately if the process has already exited
- if (process.HasExitedSafe())
- {
- return true;
- }
-
- // Register with the cancellation token then await
- using (var cancelRegistration = cancelToken.Register(() => tcs.TrySetResult(process.HasExitedSafe())))
- {
- return await tcs.Task.ConfigureAwait(false);
- }
- }
-
- /// <summary>
- /// Gets a value indicating whether the associated process has been terminated using
- /// <see cref="Process.HasExited"/>. This is safe to call even if there is no operating system process
- /// associated with the <see cref="Process"/>.
- /// </summary>
- /// <param name="process">The process to check the exit status for.</param>
- /// <returns>
- /// True if the operating system process referenced by the <see cref="Process"/> component has
- /// terminated, or if there is no associated operating system process; otherwise, false.
- /// </returns>
- private static bool HasExitedSafe(this Process process)
- {
- try
- {
- return process.HasExited;
- }
- catch (InvalidOperationException)
- {
- return true;
+ await process.WaitForExitAsync(cancelTokenSource.Token).ConfigureAwait(false);
}
}
}
diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs
index 96ee701b3..23795c6be 100644
--- a/MediaBrowser.Common/IApplicationHost.cs
+++ b/MediaBrowser.Common/IApplicationHost.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
namespace MediaBrowser.Common
@@ -36,16 +35,15 @@ namespace MediaBrowser.Common
string SystemId { get; }
/// <summary>
- /// Gets a value indicating whether this instance has pending kernel reload.
+ /// Gets a value indicating whether this instance has pending changes requiring a restart.
/// </summary>
- /// <value><c>true</c> if this instance has pending kernel reload; otherwise, <c>false</c>.</value>
+ /// <value><c>true</c> if this instance has a pending restart; otherwise, <c>false</c>.</value>
bool HasPendingRestart { get; }
/// <summary>
- /// Gets a value indicating whether this instance is currently shutting down.
+ /// Gets or sets a value indicating whether the application should restart.
/// </summary>
- /// <value><c>true</c> if this instance is shutting down; otherwise, <c>false</c>.</value>
- bool IsShuttingDown { get; }
+ bool ShouldRestart { get; set; }
/// <summary>
/// Gets the application version.
@@ -88,11 +86,6 @@ namespace MediaBrowser.Common
void NotifyPendingRestart();
/// <summary>
- /// Restarts this instance.
- /// </summary>
- void Restart();
-
- /// <summary>
/// Gets the exports.
/// </summary>
/// <typeparam name="T">The type.</typeparam>
@@ -124,12 +117,6 @@ namespace MediaBrowser.Common
T Resolve<T>();
/// <summary>
- /// Shuts down.
- /// </summary>
- /// <returns>A task.</returns>
- Task Shutdown();
-
- /// <summary>
/// Initializes this instance.
/// </summary>
/// <param name="serviceCollection">Instance of the <see cref="IServiceCollection"/> interface.</param>
diff --git a/MediaBrowser.Common/Plugins/IPluginManager.cs b/MediaBrowser.Common/Plugins/IPluginManager.cs
index 1d73de3c9..0ff9719e9 100644
--- a/MediaBrowser.Common/Plugins/IPluginManager.cs
+++ b/MediaBrowser.Common/Plugins/IPluginManager.cs
@@ -30,11 +30,6 @@ namespace MediaBrowser.Common.Plugins
IEnumerable<Assembly> LoadAssemblies();
/// <summary>
- /// Unloads all of the assemblies.
- /// </summary>
- void UnloadAssemblies();
-
- /// <summary>
/// Registers the plugin's services with the DI.
/// Note: DI is not yet instantiated yet.
/// </summary>