Many of us have been confronted many times with the need to calculate any value in a method. And the value that is calculated must be stored somewhere (for example, in a static class field). For multithreaded algorithms this is:
lock (syncObj) Interlocked.Increment(ref int) But for asynchronous methods, any blocking method is very undesirable. I tried to get by with the BlockingCollection -based queue - but unfortunately the methods work very quickly and the transfer / retrieval rate of the collection is not enough.
How exactly can you get out of the situation?
IProgress. If this is the result, then through the return value. Side effects should be avoided, especially in multi-threaded programming. - VladD pm