mirror of
https://github.com/microsoft/PowerToys
synced 2025-09-02 23:45:11 +00:00
[Runner]Check for updates and bug report on background thread (#25978)
* [Runner] CheckForUpdatesCallback function and ID_REPORT_BUG_COMMAND case in tray_icon moved to threads. * [Runner] Bool flag added to bug report thread. * [Runner] Bool flag added to CheckForUpdatesCallback thread. * [Runner] Review comments added. Uncessary mutex removed. compare_exchange_strong is used for atomic_bool variable checks.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
TwoWayPipeMessageIPC* current_settings_ipc = NULL;
|
||||
std::mutex ipc_mutex;
|
||||
std::atomic_bool g_isLaunchInProgress = false;
|
||||
std::atomic_bool isUpdateCheckThreadRunning = false;
|
||||
|
||||
json::JsonObject get_power_toys_settings()
|
||||
{
|
||||
@@ -106,7 +107,14 @@ std::optional<std::wstring> dispatch_json_action_to_module(const json::JsonObjec
|
||||
}
|
||||
else if (action == L"check_for_updates")
|
||||
{
|
||||
CheckForUpdatesCallback();
|
||||
bool expected_isUpdateCheckThreadRunning = false;
|
||||
if (isUpdateCheckThreadRunning.compare_exchange_strong(expected_isUpdateCheckThreadRunning,true))
|
||||
{
|
||||
std::thread([]() {
|
||||
CheckForUpdatesCallback();
|
||||
isUpdateCheckThreadRunning.store(false);
|
||||
}).detach();
|
||||
}
|
||||
}
|
||||
else if (action == L"request_update_state_date")
|
||||
{
|
||||
|
Reference in New Issue
Block a user