Skip to content

Commit

Permalink
fix exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
robmikh committed May 12, 2022
1 parent 151046e commit d4fd070
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Win32CaptureSample/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ int __stdcall WinMain(HINSTANCE instance, HINSTANCE, PSTR cmdLine, int cmdShow)
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
return util::ShutdownDispatcherQueueControllerAndWait(controller);
return util::ShutdownDispatcherQueueControllerAndWait(controller, static_cast<int>(msg.wParam));
}
8 changes: 4 additions & 4 deletions Win32CaptureSample/util/dispatcherqueue.desktop.interop.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace util::desktop
{
namespace impl
{
inline winrt::fire_and_forget ShutdownAndThenPostQuitMessage(winrt::Windows::System::DispatcherQueueController const& controller)
inline winrt::fire_and_forget ShutdownAndThenPostQuitMessage(winrt::Windows::System::DispatcherQueueController const& controller, int exitCode)
{
auto queue = controller.DispatcherQueue();
co_await controller.ShutdownQueueAsync();
co_await queue;
PostQuitMessage(0);
PostQuitMessage(exitCode);
co_return;
}
}
Expand All @@ -32,9 +32,9 @@ namespace util::desktop
return controller;
}

inline int ShutdownDispatcherQueueControllerAndWait(winrt::Windows::System::DispatcherQueueController const& controller)
inline int ShutdownDispatcherQueueControllerAndWait(winrt::Windows::System::DispatcherQueueController const& controller, int exitCode)
{
impl::ShutdownAndThenPostQuitMessage(controller);
impl::ShutdownAndThenPostQuitMessage(controller, exitCode);
MSG msg = {};
while (GetMessageW(&msg, nullptr, 0, 0))
{
Expand Down

0 comments on commit d4fd070

Please sign in to comment.