File tree 1 file changed +5
-6
lines changed
AsyncWorkerCollection/AsyncTaskQueue_
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 6
6
namespace dotnetCampus . Threading
7
7
{
8
8
/// <summary>
9
- /// 异步任务队列,这是重量级的方案,将会开启一个线程来做
9
+ /// 异步任务队列,将任务加入到队列里面按照顺序执行
10
10
/// </summary>
11
11
#if PublicAsInternal
12
12
internal
@@ -31,7 +31,7 @@ public AsyncTaskQueue()
31
31
/// </summary>
32
32
/// <typeparam name="T">返回结果类型</typeparam>
33
33
/// <param name="func">异步操作</param>
34
- /// <returns>isInvalid :异步操作是否有效(多任务时,如果设置了<see cref="AutoCancelPreviousTask"/>, 只会保留最后一个任务有效);result :异步操作结果</returns>
34
+ /// <returns>IsInvalid :异步操作是否有效(多任务时,如果设置了<see cref="AutoCancelPreviousTask"/>, 只会保留最后一个任务有效);Result :异步操作结果</returns>
35
35
public async Task < ( bool IsInvalid , T Result ) > ExecuteAsync < T > ( Func < Task < T > > func )
36
36
{
37
37
var task = GetExecutableTask ( func ) ;
@@ -191,7 +191,6 @@ private void Dispose(bool disposing)
191
191
}
192
192
193
193
_queue . Clear ( ) ;
194
- _autoResetEvent = null ;
195
194
_isDisposed = true ;
196
195
}
197
196
@@ -200,18 +199,18 @@ private void Dispose(bool disposing)
200
199
#region 属性及字段
201
200
202
201
/// <summary>
203
- /// 是否使用单线程完成任务.
202
+ /// 是否使用单线程完成任务
204
203
/// </summary>
205
204
public bool UseSingleThread { get ; set ; } = true ;
206
205
207
206
/// <summary>
208
- /// 自动取消以前的任务。
207
+ /// 自动取消以前的任务
209
208
/// </summary>
210
209
public bool AutoCancelPreviousTask { get ; set ; } = false ;
211
210
212
211
private bool _isDisposed ;
213
212
private readonly ConcurrentQueue < AwaitableTask > _queue = new ConcurrentQueue < AwaitableTask > ( ) ;
214
- private AsyncAutoResetEvent _autoResetEvent ;
213
+ private readonly AsyncAutoResetEvent _autoResetEvent ;
215
214
216
215
#endregion
217
216
}
You can’t perform that action at this time.
0 commit comments