@@ -702,7 +702,7 @@ namespace winrt::DrawingIslandComponents::implementation
702702 {
703703 // TODO - what is the purpose of this?
704704 UNREFERENCED_PARAMETER (point);
705- // VisualElement* selectedVisual = HitTestVisual(point);
705+ // auto selectedVisual = HitTestVisual(point);
706706 }
707707
708708 void
@@ -781,17 +781,22 @@ namespace winrt::DrawingIslandComponents::implementation
781781 DeviceLostHelper const * /* sender */ ,
782782 DeviceLostEventArgs const & /* args */ )
783783 {
784- // Recreate the text renderer's D3D and D2D devices.
785- m_output.TextRenderer ->RecreateDirect2DDevice ();
784+ // This call comes in on a Threadpool worker thread, so use the DispatcherQueue
785+ // to marshal the call to the UI thread.
786+ m_island.DispatcherQueue ().TryEnqueue (
787+ [this ] {
788+ // Recreate the text renderer's D3D and D2D devices.
789+ m_output.TextRenderer ->RecreateDirect2DDevice ();
786790
787- // Give each item an opportunity to recreate its device-dependent resources.
788- for (auto & item : m_items.Items )
789- {
790- item->OnDeviceLost ();
791- }
791+ // Give each item an opportunity to recreate its device-dependent resources.
792+ for (auto & item : m_items.Items )
793+ {
794+ item->OnDeviceLost ();
795+ }
792796
793- // Listen for device lost on the new device.
794- m_output.DeviceLostHelper .WatchDevice (m_output.TextRenderer ->GetDevice ());
797+ // Listen for device lost on the new device.
798+ m_output.DeviceLostHelper .WatchDevice (m_output.TextRenderer ->GetDevice ());
799+ });
795800 }
796801
797802
0 commit comments