Closed fomines closed 11 months ago
var registration = cancellationSource.Token.Register(() => { tcs.TrySetResult(false);
List<TaskCompletionSource<bool>> _tmp_waits = _waits.ToList();
// Not the cleanest but it works
_waits = new Queue<TaskCompletionSource<bool>>(_tmp_waits.Where(i => i != tcs));
}, useSynchronizationContext: true); //here !!! use true can fix
Fixed in Version 2.0.5
Hello. Thanks for the library! Please tell me, an exception occurs in my application and the application crashes. How can I fix it so that there are no problems? Thank you! Exception in ApiSharp\Models\AsyncResetEvent.cs:line 51. Stack: "System.AggregateException: One or more errors occurred. (Collection was modified; enumeration operation may not execute.)\r\n ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute.\r\n at System.Collections.Generic.Queueb__0() in E:\Github\ApiSharp\ApiSharp\Models\AsyncResetEvent.cs:line 51\r\n
1.Enumerator.MoveNext()\r\n at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable
1 source, Int32& length)\r\n at System.Collections.Generic.Queue1..ctor(IEnumerable
1 collection)\r\n at ApiSharp.Models.AsyncResetEvent.<>c__DisplayClass5_0.Thx.