diff --git a/src/modules/fancyzones/FancyZonesLib/EditorParameters.cpp b/src/modules/fancyzones/FancyZonesLib/EditorParameters.cpp index b7a7ea4523..0d4fe6872b 100644 --- a/src/modules/fancyzones/FancyZonesLib/EditorParameters.cpp +++ b/src/modules/fancyzones/FancyZonesLib/EditorParameters.cpp @@ -136,7 +136,7 @@ bool EditorParameters::Save(const WorkAreaConfiguration& configuration, OnThread dpiUnawareThread.submit(OnThreadExecutor::task_t{ [&]() { combinedWorkArea = FancyZonesUtils::GetAllMonitorsCombinedRect<&MONITORINFOEX::rcWork>(); - } }).wait(); + } }).get(); RECT combinedMonitorArea = FancyZonesUtils::GetAllMonitorsCombinedRect<&MONITORINFOEX::rcMonitor>(); // use dpi-unaware values @@ -198,7 +198,7 @@ bool EditorParameters::Save(const WorkAreaConfiguration& configuration, OnThread { return; } - } }).wait(); + } }).get(); float width = static_cast(monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left); float height = static_cast(monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top); diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp b/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp index 1956c57a97..1003780507 100644 --- a/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp +++ b/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp @@ -259,7 +259,7 @@ FancyZones::Run() noexcept SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE); SetThreadDpiHostingBehavior(DPI_HOSTING_BEHAVIOR_MIXED); } }) - .wait(); + .get(); m_toggleEditorEventWaiter = EventWaiter(CommonSharedConstants::FANCY_ZONES_EDITOR_TOGGLE_EVENT, [&](int err) { if (err == ERROR_SUCCESS) @@ -463,7 +463,7 @@ void FancyZones::WindowCreated(HWND window) noexcept if (!isMoved) { FancyZonesWindowProperties::StampMovedOnOpeningProperty(window); - m_dpiUnawareThread.submit(OnThreadExecutor::task_t{ [&] { MonitorUtils::OpenWindowOnActiveMonitor(window, active); } }).wait(); + m_dpiUnawareThread.submit(OnThreadExecutor::task_t{ [&] { MonitorUtils::OpenWindowOnActiveMonitor(window, active); } }).get(); } } } diff --git a/src/modules/fancyzones/FancyZonesLib/OnThreadExecutor.cpp b/src/modules/fancyzones/FancyZonesLib/OnThreadExecutor.cpp index 4f85365143..7f4ebcfc62 100644 --- a/src/modules/fancyzones/FancyZonesLib/OnThreadExecutor.cpp +++ b/src/modules/fancyzones/FancyZonesLib/OnThreadExecutor.cpp @@ -9,13 +9,17 @@ OnThreadExecutor::OnThreadExecutor() : { } -std::future OnThreadExecutor::submit(task_t task) +winrt::Windows::Foundation::IAsyncAction OnThreadExecutor::submit(task_t task) { auto future = task.get_future(); - std::lock_guard lock{ _task_mutex }; - _task_queue.emplace(std::move(task)); - _task_cv.notify_one(); - return future; + { + std::lock_guard lock{ _task_mutex }; + _task_queue.emplace(std::move(task)); + _task_cv.notify_one(); + } + + co_await winrt::resume_background(); + future.wait(); } void OnThreadExecutor::cancel() diff --git a/src/modules/fancyzones/FancyZonesLib/on_thread_executor.h b/src/modules/fancyzones/FancyZonesLib/on_thread_executor.h index 3111602f0f..621684e9d1 100644 --- a/src/modules/fancyzones/FancyZonesLib/on_thread_executor.h +++ b/src/modules/fancyzones/FancyZonesLib/on_thread_executor.h @@ -5,6 +5,7 @@ #include #include #include +#include // OnThreadExecutor allows its caller to off-load some work to a persistently running background thread. // This might come in handy if you use the API which sets thread-wide global state and the state needs @@ -17,7 +18,7 @@ public: OnThreadExecutor(); ~OnThreadExecutor(); - std::future submit(task_t task); + winrt::Windows::Foundation::IAsyncAction submit(task_t task); void cancel(); private: