This commit is contained in:
Stephan
2015-02-17 15:09:29 +01:00
committed by Shannon
parent 4c3de920c6
commit 58ce04e26b
6 changed files with 14 additions and 13 deletions

View File

@@ -128,8 +128,8 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
{
get { return true; }
}
public async Task RunAsync()
public async Task RunAsync(CancellationToken token)
{
LogHelper.Debug<XmlCacheFilePersister>("Run now.");
var doc = _content.XmlContentInternal;

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
@@ -14,7 +13,7 @@ namespace Umbraco.Web.Scheduling
/// </summary>
/// <typeparam name="T">The type of the managed tasks.</typeparam>
/// <remarks>The task runner is web-aware and will ensure that it shuts down correctly when the AppDomain
/// shuts down (ie is unloaded). FIXME WHAT DOES THAT MEAN?</remarks>
/// shuts down (ie is unloaded).</remarks>
internal class BackgroundTaskRunner<T> : IBackgroundTaskRunner<T>
where T : class, IBackgroundTask
{
@@ -373,7 +372,7 @@ namespace Umbraco.Web.Scheduling
using (bgTask) // ensure it's disposed
{
if (bgTask.IsAsync)
await bgTask.RunAsync(); // fixme should pass the token along?!
await bgTask.RunAsync(token);
else
bgTask.Run();
}

View File

@@ -44,11 +44,11 @@ namespace Umbraco.Web.Scheduling
base.Run();
}
public override async Task RunAsync()
public override async Task RunAsync(CancellationToken token)
{
if (_latch != null)
_latch.Dispose();
await base.RunAsync();
await base.RunAsync(token);
}
public WaitHandle Latch

View File

@@ -1,4 +1,5 @@
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Umbraco.Web.Scheduling
@@ -16,9 +17,10 @@ namespace Umbraco.Web.Scheduling
/// <summary>
/// Runs the task asynchronously.
/// </summary>
/// <param name="token">A cancellation token.</param>
/// <returns>A <see cref="Task"/> instance representing the execution of the background task.</returns>
/// <exception cref="NotImplementedException">The background task cannot run asynchronously.</exception>
Task RunAsync();
Task RunAsync(CancellationToken token);
/// <summary>
/// Indicates whether the background task can run asynchronously.

View File

@@ -53,7 +53,7 @@ namespace Umbraco.Web.Scheduling
/// Implements IBackgroundTask.RunAsync().
/// </summary>
/// <remarks>Classes inheriting from <c>RecurringTaskBase</c> must implement <c>PerformRun</c>.</remarks>
public virtual async Task RunAsync()
public virtual async Task RunAsync(CancellationToken token)
{
await PerformRunAsync();
Repeat();