You can also see asynchronous I / O. In this style, you will start the operation with a file from the main thread, then it will continue to work in the background and when it is completed, it will call the callback that you specified. In the meantime, you can continue to do other things (for example, process data). For example, you can run an asynchronous operation to read the next 1000 bytes, and then process the 1000 bytes that you already have, and then wait for the next kilobyte.
Unfortunately, programming asynchronous operations in C # is a little painful. There is a sample MSDN , but this is not at all nice. This can be well solved in F # using asynchronous workflows. I wrote an article that explains the problem and shows how to do a similar thing using Iterators #.
A more promising solution for C # is the Wintellect PowerThreading library, which supports a similar trick using C # iterators. There is a good introductory article on the MSDN Concurrency Cases of Jeffrey Richter.
source share