diff --git a/Falcon.SugarApi/BackTask/BackgroundLongTask.cs b/Falcon.SugarApi/BackTask/BackgroundLongTask.cs
index 2a37089..d90abb5 100644
--- a/Falcon.SugarApi/BackTask/BackgroundLongTask.cs
+++ b/Falcon.SugarApi/BackTask/BackgroundLongTask.cs
@@ -8,7 +8,7 @@ namespace Falcon.SugarApi.BackTask
///
/// 长时间执行的后台任务
///
- public abstract class BackgroundLongTask : BackgroundService
+ public abstract class BackgroundLongTask : BackgroundService, IDisposable
{
///
/// 要执行的任务
@@ -70,5 +70,13 @@ namespace Falcon.SugarApi.BackTask
this.TokenSource.Cancel();
return base.StopAsync(cancellationToken);
}
+
+ ///
+ /// 释放空间,结束任务
+ ///
+ public override void Dispose() {
+ this.TokenSource.Cancel();
+ base.Dispose();
+ }
}
}