Parallel.ForEach never returns (sometimes), weird timing issue?

I have got the following code and every once in a while, the call never returns…

Parallel.ForEach(AWSing, po_network, lang => { bool uploadokay = false; while (!uploadokay) { try { // network operation here } catch (Exception e) { // logging to disk here System.Threading.Thread.Sleep(700); } } }); 

Unfortunately, it only happens may be 1 time out of a 100 runs. Interestingly, if I don’t have the sleep call, the failure rate is higher. Also, not all items in AWSing are processed either, usually just one is left. AWSing is string []. If anyone can give me any insight, I’ll really appreciate it!

submitted by /u/DraconPern
[link] [comments]

Leave a Reply