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

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
McSaverCharting
Newbie
Newbie
Posts: 10
Joined: Mon Jan 29, 2024 12:00 am

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

Post by McSaverCharting » Wed Mar 13, 2024 5:12 pm

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)

Pep
Site Admin
Site Admin
Posts: 3273
Joined: Fri Nov 14, 2003 5:00 am
Contact:

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

Post by Pep » Fri Mar 15, 2024 9:39 am

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

McSaverCharting
Newbie
Newbie
Posts: 10
Joined: Mon Jan 29, 2024 12:00 am

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

Post by McSaverCharting » Fri Apr 19, 2024 1:55 am

Problem solved. Lesson learned. Don't update your charts on a background thread.

Marc
Site Admin
Site Admin
Posts: 1217
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

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

Post by Marc » Mon Apr 22, 2024 9:50 am

Thanks for the feedback,

Regards,
Marc
Steema Support

Post Reply