Question. How to implement asynchrony, without resorting to third-party libraries. In 4.5 we have await and async , in 4.0 we have Task Task<T> . In 3.5 we only have BeginInvoke

Interested in the principle of describing an asynchronous method, which in turn will call within itself a number of methods, in the same thread, or in another, and wait for them to complete, with the possibility of obtaining the result of the method, or without ( void method). The example in 4.5 looks like this:

 void async DoIt() { ... var a = await AsyncDoItSomething(); ... } 
  • one
    Where does such a restriction come from - “without resorting to third-party libraries”? - Pavel Mayorov
  • @PavelMayorov does not want to carry a wagon and a small trolley of third-party libraries, the more standard means you can implement, and this is more interesting. - ParanoidPanda
  • one
    In 3.5 we only have BeginInvoke - so why not use it? - Grundy
  • 2
    Add to the question what you mean by the description principle, the same await with the result, and not just shoot in an unknown direction. Now it is not clear what exactly you want to get. In principle, no one bothers to look at the source Task and take it. what do you need for example. - Grundy
  • four
    nuget.org/packages/TaskParallelLibrary is the official (tm) implementation of Task <T> for 3.5 - PashaPash

0