bool _is_thd_runing(std::future<int> &fut)
{
bool bRunning = false;
try
{
std::chrono::milliseconds span(1);
if (fut.wait_for(span) == std::future_status::timeout)
{
bRunning = true;
}
}
catch (const std::exception&)
{
}
return bRunning;
}
std::future<int> fut;
auto func = [&]()->int
{
do something;
return 0;
};
fut = std::async(func);
bool is_running = _is_thd_runing(fut);