mercredi 9 juin 2021

Is it Possible to terminate the std::async thread?

I have the code below which I am calling it asynchronously for downloading a file, I want to terminate the thread ? How to achieive this ?

std::future<BOOL> fut = std::async(std::launch::async,&download::downloadBlob2File,&t_oftcdownload,stol(blocksize), downldUrl, token,name, path, ID);
 std::chrono::hours span (2);
 int t_iResult = -1;

 if (fut.wait_for(span)==std::future_status::timeout)
 {
  t_iResult=0;
 }

Aucun commentaire:

Enregistrer un commentaire