Description
When trying to directly pass the Invalidate method of a Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl instance as the callback argument of the TryEnqueue method of a DispatcherQueue instance an InvalidCastException is thrown.
When passing a lambda expression that just calls the Invalidate method, the exception is not thrown!
Steps To Reproduce
The following should do the trick (I have not verified this outside of my repo):
DispatcherQueue.TryEnqueue(GraphCanvas.Invalidate);
where GraphCanvas is a Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl instance.
The following code does not throw the exception:
DispatcherQueue.TryEnqueue(() => GraphCanvas.Invalidate());
Expected Behavior
No InvalidCastException is thrown
Version Info
.NET 9.0 Framework
Additional Context
The following image shows one such exception with a stack trace:
