Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: How to end up a thread while encounter a task exception in a ".then" contuation task

$
0
0
Hi Joecc,

Every task could be running on a different thread, but really they are running on a thread pool so there isn't the cost and expense of creating a new thread each time.

If you don't care about the OnButtonClickRun being asynchronous then I would recommend code like the following. I'm not sure how your above code was compiling because extract_json is asynchronous and returns a task<json::value>. The reason you might be confused with your first code snippet is because you are not using a task based continuation, the http_response assignment is never going to throw an exception.
json::value json_obj;
try
{
    http_response response = client.request(request).get();
    json_objc = response.extract_json().get();
} catch(const std::exception &e)
{
    // Handle and return
    return;
}
// If you have reached here the json_obj variable contains the result....
Steve

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>