From 1163d119b34ae0dc01fd5ceceeb166e2b4e894db Mon Sep 17 00:00:00 2001 From: Tom Early Date: Sun, 2 Aug 2020 06:32:11 -0700 Subject: [PATCH] start WiresX cmd handler in try{} --- src/cwiresxcmdhandler.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cwiresxcmdhandler.cpp b/src/cwiresxcmdhandler.cpp index fb9ffc5..d22386c 100644 --- a/src/cwiresxcmdhandler.cpp +++ b/src/cwiresxcmdhandler.cpp @@ -74,8 +74,16 @@ bool CWiresxCmdHandler::Init(void) // reset stop flag keep_running = true; - // start thread; - m_Future = std::async(std::launch::async, &CWiresxCmdHandler::Thread, this); + try + { + m_Future = std::async(std::launch::async, &CWiresxCmdHandler::Thread, this); + } + catch(const std::exception& e) + { + std::cerr << "ERROR: could not start WiresX Command Handler: " << e.what() << std::endl; + return false; + } + // done return true; @@ -95,12 +103,12 @@ void CWiresxCmdHandler::Close(void) void CWiresxCmdHandler::Thread() { - std::cout << "Starting WiresX Command Handler" << std:: endl; + std::cout << "*********Starting WiresX Command Handler*********" << std:: endl; while (keep_running) { Task(); } - std::cout << "WiresX Command Handler has stopped" << std::endl; + std::cout << "*********WiresX Command Handler has stopped*********" << std::endl; } ////////////////////////////////////////////////////////////////////////////////////////