RPC_E_WRONG_THREAD: Real-time Win2D particle canvas crashing during heavy asynchronous calculations

Core Blast Solutions 0 Reputation points
2026-07-02T19:25:51.4+00:00

Hello everyone,

I am currently developing a desktop engineering-utility app for my company, Coreblastsolutions. The app is designed for industrial operations, helping engineers run real-time particle trajectory simulations to estimate nozzle wear and abrasive medium degradation (steel shot vs. garnet) over active blasting hours.

We have built the app using WinUI 3 (Windows App SDK 1.6), target-compiled on .NET 8 (Windows App SDK 10.0.19041).

To visualize the nozzle erosion, we are using Microsoft's Win2D (Microsoft.Graphics.Win2D) library via a CanvasAnimatedControl. The mathematical calculations run asynchronously in a background thread task to keep the desktop UI responsive.

The Problem

Every time the user changes the nozzle diameter or ramps up the pressure (PSI) slider, our computational engine recalculates millions of particle points. We offload these calculations to Task.Run().

However, during rapid input changes, the app crashes and throws a fatal System.Exception with the error code 0x8001010E (RPC_E_WRONG_THREAD). It appears that when the background math thread finishes, it's trying to push updated vectors to our UI rendering loop without proper marshalling, or our render thread is accessing disposed inputs.

Tech Specs

  • Operating System: Windows 11 Pro (Build 22631, x64)

Target Framework: .net8.0-windows10.0.19041.0

SDK Reference: Microsoft.WindowsAppSDK (v1.6.240829007)

Graphics Package: Microsoft.Graphics.Win2D (v1.2.0)

Hardware Setup: Tested on both high-end workstation GPUs (NVIDIA RTX 4070) and Intel Iris Xe Integrated Graphics (reproduces on both).

Exception Stack Trace

System.Exception: The application called an interface that was marshalled for a different thread. 
(Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
   at WinRT.BaseActivateInstance(String activatableClassId)
   at Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedControl.get_CanvasDevice()
   at CoreBlastSolutions.Views.SimulationPage.NozzleCanvas_Update(ICanvasAnimatedControl sender, CanvasAnimatedUpdateEventArgs args)
   at System.Threading.Tasks.Task.<>c.
Windows for home | Windows 11 | Performance and system failures
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.