后台长时任务重写在释放时候停止任务
This commit is contained in:
parent
4077501379
commit
5fa1a78ddf
|
@ -8,7 +8,7 @@ namespace Falcon.SugarApi.BackTask
|
|||
/// <summary>
|
||||
/// 长时间执行的后台任务
|
||||
/// </summary>
|
||||
public abstract class BackgroundLongTask : BackgroundService
|
||||
public abstract class BackgroundLongTask : BackgroundService, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// 要执行的任务
|
||||
|
@ -70,5 +70,13 @@ namespace Falcon.SugarApi.BackTask
|
|||
this.TokenSource.Cancel();
|
||||
return base.StopAsync(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放空间,结束任务
|
||||
/// </summary>
|
||||
public override void Dispose() {
|
||||
this.TokenSource.Cancel();
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user