From 3acfd73d86a06fc024e4293e37aa4e0fe226409c Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Sun, 10 Mar 2013 01:45:16 -0500 Subject: fixed scheduled tasks firing too early --- .../BaseApplicationHost.cs | 65 ++++++++++++++++++++-- 1 file changed, 61 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.Common.Implementations/BaseApplicationHost.cs') diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index a9c73d0e9..1950c1428 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -13,7 +13,6 @@ using MediaBrowser.Common.Security; using MediaBrowser.Common.Updates; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.System; using MediaBrowser.Model.Updates; using SimpleInjector; using System; @@ -26,6 +25,10 @@ using System.Threading.Tasks; namespace MediaBrowser.Common.Implementations { + /// + /// Class BaseApplicationHost + /// + /// The type of the T application paths type. public abstract class BaseApplicationHost : IApplicationHost where TApplicationPathsType : class, IApplicationPaths, new() { @@ -87,6 +90,7 @@ namespace MediaBrowser.Common.Implementations /// /// Gets assemblies that failed to load /// + /// The failed assemblies. public List FailedAssemblies { get; protected set; } /// @@ -148,11 +152,31 @@ namespace MediaBrowser.Common.Implementations /// /// The kernel. protected ITaskManager TaskManager { get; private set; } + /// + /// Gets the security manager. + /// + /// The security manager. protected ISecurityManager SecurityManager { get; private set; } + /// + /// Gets the package manager. + /// + /// The package manager. protected IPackageManager PackageManager { get; private set; } + /// + /// Gets the HTTP client. + /// + /// The HTTP client. protected IHttpClient HttpClient { get; private set; } + /// + /// Gets the network manager. + /// + /// The network manager. protected INetworkManager NetworkManager { get; private set; } + /// + /// Gets the configuration manager. + /// + /// The configuration manager. protected IConfigurationManager ConfigurationManager { get; private set; } /// @@ -187,7 +211,21 @@ namespace MediaBrowser.Common.Implementations FindParts(); - Task.Run(() => ConfigureAutoRunAtStartup()); + await RunStartupTasks().ConfigureAwait(false); + } + + /// + /// Runs the startup tasks. + /// + /// Task. + protected virtual Task RunStartupTasks() + { + return Task.Run(() => + { + Resolve().AddTasks(GetExports(false)); + + Task.Run(() => ConfigureAutoRunAtStartup()); + }); } /// @@ -202,6 +240,10 @@ namespace MediaBrowser.Common.Implementations /// The name of the log file prefix. protected abstract string LogFilePrefixName { get; } + /// + /// Gets the configuration manager. + /// + /// IConfigurationManager. protected abstract IConfigurationManager GetConfigurationManager(); /// @@ -210,8 +252,6 @@ namespace MediaBrowser.Common.Implementations protected virtual void FindParts() { Plugins = GetExports(); - - Resolve().AddTasks(GetExports(false)); } /// @@ -236,6 +276,7 @@ namespace MediaBrowser.Common.Implementations /// /// Registers resources that classes will depend on /// + /// Task. protected virtual Task RegisterResources() { return Task.Run(() => @@ -509,10 +550,23 @@ namespace MediaBrowser.Common.Implementations } } + /// + /// Restarts this instance. + /// public abstract void Restart(); + /// + /// Gets or sets a value indicating whether this instance can self update. + /// + /// true if this instance can self update; otherwise, false. public abstract bool CanSelfUpdate { get; } + /// + /// Checks for update. + /// + /// The cancellation token. + /// The progress. + /// Task{CheckForUpdateResult}. public abstract Task CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress progress); /// @@ -529,6 +583,9 @@ namespace MediaBrowser.Common.Implementations EventHelper.QueueEventIfNotNull(ApplicationUpdated, this, new GenericEventArgs { Argument = package.version }, Logger); } + /// + /// Shuts down. + /// public abstract void Shutdown(); } } -- cgit v1.2.3