Skip to content

Commit

Permalink
reverse async in IPC send message
Browse files Browse the repository at this point in the history
  • Loading branch information
fxliang committed Aug 27, 2024
1 parent 28ace8e commit 069b37d
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions WeaselIPC/WeaselClientImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "stdafx.h"
#include "WeaselClientImpl.h"
#include <StringAlgorithm.hpp>
#include <future>
#include <chrono>

using namespace weasel;

Expand Down Expand Up @@ -197,29 +195,7 @@ LRESULT ClientImpl::_SendMessage(WEASEL_IPC_COMMAND Msg,
DWORD lParam) {
try {
PipeMessage req{Msg, wParam, lParam};
LRESULT ret = 0;
switch (Msg) {
case WEASEL_IPC_PROCESS_KEY_EVENT: {
auto future = std::async(std::launch::async, [this, &req]() {
return channel.Transact(req);
});
// wait Transact complete or overtime
if (future.wait_for(std::chrono::seconds(2)) ==
std::future_status::timeout) {
// Transact overtime
ret = 0;
} else {
// Transact complete
ret = future.get();
}
break;
}
default: {
ret = channel.Transact(req);
break;
}
}
return ret;
return channel.Transact(req);
} catch (DWORD /* ex */) {
return 0;
}
Expand Down

0 comments on commit 069b37d

Please sign in to comment.