c# - Handle cancelled task and task exceptions in Task.WaitAll? -


I am using TPL to crawl a set of URLs and then processing something. {{......}); } Work. Wait all (work);

The issue is that Tasks. Waiting seems like it will often throw an exception because a work has been canceled. I understand that httpclient.getStringAsync can not always ensure success, so if I have an exception I would like to add a retrain log in httpClient.GetStringAsync . To do this, what would be the appropriate approach

You can easily get the GetStringAsync For code> with loop, which is no exception or tries to reach again the limit of effort. I store the work and I am using it for the wait if I reach the retrace limit without success, the exception will be redone:

  Async Tasks & lt; String & gt; GetStringAsync (HTTP Client Client, String URL, Intit Retrieves) {Task & Lt; String & gt; Work = null; For (Int i = 0; I   

You may also be able to do this as an extension method on HttpClient :

  Fixed async Tasks & lt ; String & gt; GetStringAsync (This HttpClient Client, String URL, Intit Retrieves);    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -