-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TgBot++: clientapp/win32: Don't block UI thread for socket-op
- Also introduce BlockingOperation class, trying to commonize code
- Loading branch information
Showing
10 changed files
with
276 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#define _CRT_SECURE_NO_WARNINGS | ||
|
||
#include "BlockingOperation.h" | ||
|
||
#include <WinUser.h> | ||
|
||
#include "UIComponents.h" | ||
|
||
bool BlockingOperation::shouldBlockRequest(HWND hDlg) const { | ||
if (m_enabled) { | ||
auto &loader = StringLoader::getInstance(); | ||
MessageBox(hDlg, loader.getString(IDS_OPERATION_ACTIVE).c_str(), | ||
loader.getString(IDS_FAILED).c_str(), WARNING_DIALOG); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void BlockingOperation::start() { | ||
SetCursor(LoadCursor(NULL, IDC_WAIT)); | ||
m_enabled = true; | ||
} | ||
|
||
void BlockingOperation::stop() { | ||
SetCursor(LoadCursor(NULL, IDC_ARROW)); | ||
m_enabled = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include <wtypes.h> | ||
|
||
class BlockingOperation { | ||
public: | ||
bool shouldBlockRequest(HWND hDlg) const; | ||
void start(); | ||
void stop(); | ||
|
||
private: | ||
bool m_enabled; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.