wheelsmanx

Async Thread Test

Nov 29th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <future>
  5. #include <thread>
  6. #include <Windows.h>
  7. using namespace std;
  8.  
  9. int returnFunction(string temp) {
  10. while (true) {
  11. Sleep(2000);
  12. cout << ".";
  13. }
  14. return 4;
  15. }
  16.  
  17.  
  18. void main() {
  19.  
  20. auto future = std::async(returnFunction, "test");
  21. int simple = future.get();
  22.  
  23. cout << simple << endl;
  24. system("pause");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment