I have a UWP app that uses the TileControl from the Windows Community Toolkit (Microsoft.Toolkit.Uwp.UI.Controls.TileControl), and I use a *.png file as the ImageSource. This seems to works fine, except when I leave & return to the app. It seems to only be a problem sometimes, but I'm not sure why. From what I can tell, it only causes a problem if I leave the app long enough to trigger the LeavingBackground event of the app. Here are the last few lines of output from the Immediate window:
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll
System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed.
at Microsoft.Toolkit.Uwp.UI.Controls.TileControl.c_DisplayClass47_0.b0(LoadedImageSurface s, LoadedImageSourceLoadCompletedEventArgs e) System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed.
at Microsoft.Toolkit.Uwp.UI.Controls.TileControl.cDisplayClass47_0.b_0(LoadedImageSurface s, LoadedImageSourceLoadCompletedEventArgs e)
There are multiple TileControl(s), and I am suspecting (although I am not the most knowledgeable about overlapping asynchronous and tasks) that the problem has something to do with loading the images at the same time. The ImageSource is specified directly in the XAML, and does not change, although the TileControl is part of a DataTemplate that is used multiple times. I have almost no experience debugging this kind of problem, so I'm not quite sure what to do next. Can somebody help me? Thanks.