Eric Reed 12 years ago
commit a26ef05e7a

@ -106,7 +106,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
/// <param name="task">The task.</param> /// <param name="task">The task.</param>
private void QueueScheduledTask(IScheduledTaskWorker task) private void QueueScheduledTask(IScheduledTaskWorker task)
{ {
var type = task.GetType(); var type = task.ScheduledTask.GetType();
lock (_taskQueue) lock (_taskQueue)
{ {
@ -173,14 +173,46 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
return ((ScheduledTaskWorker)task).Execute(); return ((ScheduledTaskWorker)task).Execute();
} }
/// <summary>
/// Called when [task executing].
/// </summary>
/// <param name="task">The task.</param>
internal void OnTaskExecuting(IScheduledTask task) internal void OnTaskExecuting(IScheduledTask task)
{ {
EventHelper.QueueEventIfNotNull(TaskExecuting, task, EventArgs.Empty, Logger); EventHelper.QueueEventIfNotNull(TaskExecuting, task, EventArgs.Empty, Logger);
} }
/// <summary>
/// Called when [task completed].
/// </summary>
/// <param name="task">The task.</param>
/// <param name="result">The result.</param>
internal void OnTaskCompleted(IScheduledTask task, TaskResult result) internal void OnTaskCompleted(IScheduledTask task, TaskResult result)
{ {
EventHelper.QueueEventIfNotNull(TaskExecuting, task, new GenericEventArgs<TaskResult> { Argument = result }, Logger); EventHelper.QueueEventIfNotNull(TaskExecuting, task, new GenericEventArgs<TaskResult> { Argument = result }, Logger);
ExecuteQueuedTasks();
}
/// <summary>
/// Executes the queued tasks.
/// </summary>
private void ExecuteQueuedTasks()
{
// Execute queued tasks
lock (_taskQueue)
{
foreach (var type in _taskQueue.ToList())
{
var scheduledTask = ScheduledTasks.First(t => t.ScheduledTask.GetType() == type);
if (scheduledTask.State == TaskState.Idle)
{
((ScheduledTaskWorker)scheduledTask).Execute();
_taskQueue.Remove(type);
}
}
}
} }
} }
} }

@ -134,6 +134,11 @@ namespace MediaBrowser.ServerApplication
Logger.ErrorException("UnhandledException", exception); Logger.ErrorException("UnhandledException", exception);
MessageBox.Show("Unhandled exception: " + exception.Message); MessageBox.Show("Unhandled exception: " + exception.Message);
if (!Debugger.IsAttached)
{
Environment.Exit(System.Runtime.InteropServices.Marshal.GetHRForException(exception));
}
} }
/// <summary> /// <summary>

@ -43,12 +43,13 @@ namespace MediaBrowser.WebDashboard.Api
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
/// <param name="taskManager">The task manager.</param> /// <param name="taskManager">The task manager.</param>
/// <param name="userManager">The user manager.</param> /// <param name="userManager">The user manager.</param>
public DashboardInfoWebSocketListener(IServerApplicationHost appHost, ILogger logger, ITaskManager taskManager, IUserManager userManager) public DashboardInfoWebSocketListener(IServerApplicationHost appHost, ILogger logger, ITaskManager taskManager, IUserManager userManager, ILibraryManager libraryManager)
: base(logger) : base(logger)
{ {
_appHost = appHost; _appHost = appHost;
_taskManager = taskManager; _taskManager = taskManager;
_userManager = userManager; _userManager = userManager;
_libraryManager = libraryManager;
} }
/// <summary> /// <summary>

@ -382,7 +382,7 @@ var Dashboard = {
setTimeout(function () { setTimeout(function () {
Dashboard.reloadPageWhenServerAvailable(); Dashboard.reloadPageWhenServerAvailable();
}, 500); }, 250);
}).fail(function () { }).fail(function () {
Dashboard.suppressAjaxErrors = false; Dashboard.suppressAjaxErrors = false;
@ -391,10 +391,17 @@ var Dashboard = {
reloadPageWhenServerAvailable: function (retryCount) { reloadPageWhenServerAvailable: function (retryCount) {
ApiClient.getSystemInfo().done(function () { ApiClient.getSystemInfo().done(function (info) {
Dashboard.reloadPage();
// If this is back to false, the restart completed
if (!info.HasPendingRestart) {
Dashboard.reloadPage();
} else {
Dashboard.reloadPageWhenServerAvailable(retryCount);
}
}).fail(function () { }).fail(function () {
setTimeout(function () { setTimeout(function () {
retryCount = retryCount || 0; retryCount = retryCount || 0;

Loading…
Cancel
Save