Page 1 of 1

Maui App crash: Collection was modified; enumeration operation may not execute.

Posted: Wed Mar 13, 2024 5:12 pm
by 30297515
Using TeeChart released version: 6.2024.2.19
Build: Maui Application, Platform: Windows
Run on a Windows 11 operating system
Development Environment: Visual Studio 2022 (64 bit) 17.8.7


I randomly see the following error just after my page is loaded. My page has five different charts. This occurs 5-10% of the time. I click an item that then loads data for the charts and the application crashes. I do not have a simple example nor one that is 100% reproducible, but I was hoping you might be able to look at your source and have a guess as to what would be the most likely cause. Seems like there is some sort of timing issue.

Any help would be appreciated.

Exception = {"Collection was modified; enumeration operation may not execute."}

at Steema.TeeChart.Chart.InternalMinMax(Axis aAxis, Boolean isMin, Boolean isX)
at Steema.TeeChart.Axis.CalcMinMax(Double& min, Double& max)
at Steema.TeeChart.Axis.AdjustMaxMin()
at Steema.TeeChart.Axes.AdjustMaxMin()
at Steema.TeeChart.Chart.CalcAxisRect()
at Steema.TeeChart.Chart.InternalDraw(Boolean noTools)
at Steema.TeeChart.Chart.InternalDraw()
at Steema.TeeChart.Maui.TChart.Draw(ICanvas g, RectF rect)
at Microsoft.Maui.Graphics.Win2D.W2DGraphicsView.OnDraw(CanvasControl sender, CanvasDrawEventArgs args)
at WinRT._EventSource_global__Windows_Foundation_TypedEventHandler_global__Microsoft_Graphics_Canvas_UI_Xaml_CanvasControl__global__Microsoft_Graphics_Canvas_UI_Xaml_CanvasDrawEventArgs_.EventState.<GetEventInvoke>b__1_0(CanvasControl sender, CanvasDrawEventArgs args)
at ABI.Windows.Foundation.TypedEventHandler`2.Do_Abi_Invoke[TSenderAbi,TResultAbi](Void* thisPtr, TSenderAbi sender, TResultAbi args)

Re: Maui App crash: Collection was modified; enumeration operation may not execute.

Posted: Fri Mar 15, 2024 9:39 am
by Pep
Hello,

it's difficult to check what could be the cause without having an example to reproduce it, but we're going to try.
Does this also happens by using SampleValues for all the series in your aplication ? this will help in order to find where problem is.
Also if the problem happens when user clicks in any specific series type.

Thanks

Re: Maui App crash: Collection was modified; enumeration operation may not execute.

Posted: Fri Apr 19, 2024 1:55 am
by 30297515
Problem solved. Lesson learned. Don't update your charts on a background thread.

Re: Maui App crash: Collection was modified; enumeration operation may not execute.

Posted: Mon Apr 22, 2024 9:50 am
by Marc
Thanks for the feedback,

Regards,
Marc