From da3fece8cd8388fb80977e32ec67e9e9ed892818 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 4 Aug 2022 23:57:33 +0300 Subject: [PATCH] Weather: Wait a bit before refreshing when network connectivity is restored This is so that we avoid a situation where the browser was looping on trying to display the error page. Each navigation request was erroring out, and the error said something along the lines of "Your computer went to sleep". Indeed, this bug could be reproduced by hibernating the computer and then waking it up - it seemed to occur pretty frequently, especially on battery, when the power budget is more constrained, and thus the speed of the PC as well. Hopefully, this commit and the previous one addresses this issue. --- ep_weather_host/ep_weather_host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ep_weather_host/ep_weather_host.c b/ep_weather_host/ep_weather_host.c index d82ae04..9413248 100644 --- a/ep_weather_host/ep_weather_host.c +++ b/ep_weather_host/ep_weather_host.c @@ -75,7 +75,8 @@ HRESULT STDMETHODCALLTYPE INetworkListManagerEvents_ConnectivityChanged(void* _t { printf("[Network Events] Internet connection status is: Available.\n"); LONG64 dwUpdateSchedule = InterlockedAdd64(&_this->dwUpdateSchedule, 0); - PostMessageW(_this->hWnd, EP_WEATHER_WM_FETCH_DATA, 0, 0); + SetTimer(_this->hWnd, EP_WEATHER_TIMER_REQUEST_REFRESH, EP_WEATHER_TIMER_REQUEST_REFRESH_DELAY, NULL); + //PostMessageW(_this->hWnd, EP_WEATHER_WM_FETCH_DATA, 0, 0); SetTimer(_this->hWnd, EP_WEATHER_TIMER_SCHEDULE_REFRESH, dwUpdateSchedule, NULL); printf("[Network Events] Reinstalled refresh timer.\n"); }