File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -29,14 +29,18 @@ private static readonly Task<bool> CompletedSourceTask
29
29
= Task . FromResult ( true ) ;
30
30
31
31
/// <summary>
32
- /// 异步等待一个信号,需要await
32
+ /// 异步等待一个信号,需要 await 等待
33
+ /// <para></para>
34
+ /// 可以通过返回值是 true 或 false 判断当前是收到信号还是此类被释放
33
35
/// </summary>
34
- /// <returns>如果是正常解锁,那么返回 true 值。如果是对象调用 <see cref="Dispose"/> 释放,那么返回 false 值</returns>
36
+ /// <returns>
37
+ /// 如果是正常解锁,那么返回 true 值。如果是对象调用 <see cref="Dispose"/> 释放,那么返回 false 值
38
+ /// </returns>
35
39
public Task < bool > WaitOneAsync ( )
36
40
{
37
41
lock ( _locker )
38
42
{
39
- if ( _isDisposing )
43
+ if ( _isDisposed )
40
44
{
41
45
throw new ObjectDisposedException ( nameof ( AsyncAutoResetEvent ) ) ;
42
46
}
@@ -78,7 +82,7 @@ public void Set()
78
82
}
79
83
80
84
// 如果这个类被释放了,那么返回 false 值
81
- result = ! _isDisposing ;
85
+ result = ! _isDisposed ;
82
86
}
83
87
84
88
releaseSource ? . SetResult ( result ) ;
@@ -91,7 +95,7 @@ public void Dispose()
91
95
{
92
96
lock ( _locker )
93
97
{
94
- _isDisposing = true ;
98
+ _isDisposed = true ;
95
99
}
96
100
97
101
GC . SuppressFinalize ( this ) ;
@@ -111,7 +115,7 @@ public void Dispose()
111
115
}
112
116
}
113
117
114
- private bool _isDisposing ;
118
+ private bool _isDisposed ;
115
119
116
120
private readonly object _locker = new object ( ) ;
117
121
You can’t perform that action at this time.
0 commit comments