Hi Chris,
You are calling wait on the task returned from the connect(...) function call. Any time you call wait/get on a task if that task didn't complete and threw an exception, the exception will be re-thrown. If you are going to synchronously wait for the connect, as done in your code snippet, you'll need to have a try catch around the wait() call. Something like the following:
Steve
You are calling wait on the task returned from the connect(...) function call. Any time you call wait/get on a task if that task didn't complete and threw an exception, the exception will be re-thrown. If you are going to synchronously wait for the connect, as done in your code snippet, you'll need to have a try catch around the wait() call. Something like the following:
try
{
cbclient.connect(host).then([host](pplx::task<void> t)
{
t.get();
connected = true;
::log("Connected to %ls", host.c_str());
}).wait();
} catch(const websocket_exception &e)
{
// Handle connection error...
}
If you are new to programming with tasks I highly recommend you take a look at the following on msdn about using tasks.Steve