Skip to content

Commit 6f0fe43

Browse files
adpa-msAdib Parkar
andauthored
Add proper island cleanup flow to DrawingIsland sample app (#344)
Co-authored-by: Adib Parkar <[email protected]>
1 parent 486dff5 commit 6f0fe43

File tree

1 file changed

+7
-5
lines changed
  • Samples/Islands/DrawingIsland/DrawingCppTestApp

1 file changed

+7
-5
lines changed

Samples/Islands/DrawingIsland/DrawingCppTestApp/WinMain.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,25 @@ int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
2121
auto controller{ winrt::DispatcherQueueController::CreateOnCurrentThread() };
2222
auto queue = controller.DispatcherQueue();
2323

24+
auto compositor = winrt::Compositor();
25+
auto island = winrt::DrawingIsland(compositor).Island();
26+
2427
auto window = winrt::AppWindow::Create();
2528
window.AssociateWithDispatcherQueue(queue);
26-
window.Closing([&](auto&&, auto&&)
29+
window.Closing(
30+
[island, queue](auto&&, auto&&)
2731
{
32+
island.Close();
2833
queue.EnqueueEventLoopExit();
2934
});
3035

3136
window.Title(L"Drawing C++ TestApp");
3237
window.Show();
3338

34-
auto compositor = winrt::Compositor();
35-
auto drawing = winrt::DrawingIsland(compositor);
36-
3739
auto siteBridge = winrt::DesktopChildSiteBridge::Create(compositor, window.Id());
3840
siteBridge.ResizePolicy(winrt::ContentSizePolicy::ResizeContentToParentWindow);
3941
siteBridge.Show();
40-
siteBridge.Connect(drawing.Island());
42+
siteBridge.Connect(island);
4143

4244
// Move initial focus to the island.
4345
auto focusNavigationHost = winrt::InputFocusNavigationHost::GetForSiteBridge(siteBridge);

0 commit comments

Comments
 (0)