chanan / BlazorStrap

Bootstrap 4 Components for Blazor Framework
https://blazorstrap.io
The Unlicense
920 stars 157 forks source link

InvalidOperationException at Toaster #582

Closed EMaderbacher closed 1 year ago

EMaderbacher commented 1 year ago

I get from time to time following exceptions:

Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
   at BlazorStrap.Shared.Components.Common.BSToastBase.TimerOnElapsed(Object sender, ElapsedEventArgs e)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException: Object reference not set to an instance of an object.
   at BlazorStrap.Shared.Components.Common.BSToastBase.<TimerOnElapsed>b__69_0(Toasts q)
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
   at BlazorStrap.Shared.Components.Common.BSToastBase.TimerOnElapsed(Object sender, ElapsedEventArgs e)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

Version: 5.1.101 using Bootstrap 5. I'll try to find out the reason and if I can find it, I'll submit a pull request

jbomhold3 commented 1 year ago

ConcurrentQueue would fix the first one. Second not really sure myself.