System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
I am adding/removing from an ObservableCollection which is not on a UI thread.
I have a method names EnqueueReport to add to the colleciton and a DequeueReport to remove from the colleciton.
The flow of steps is as below :-
- 1.call EnqueueReport whenever a new report is requested
- call a method every few seconds to check if the report is generated (this has a foreach loop that checks the generated status of all reports in ObservableCollection)
- call DequeueReport if the report is generated
I am not much in C# libraries. Can someone please guide me on this?
See Question&Answers more detail:os