I use a library that makes asynchronous calls, and when the response is returned, the callback method is called with the result. This is a simple example, but now I find an obstacle. How to make several calls to asynchronous methods and wait (without blocking) for them? When I receive data from the entire service, I would like to call my own callback method, which will receive two (or more) values returned by the async method.
What is the right scheme to follow here? By the way, I can't change the library to use TPL or anything else ... I need to live with it.
public static void GetDataAsync(Action<int, int> callback) { Service.Instance.GetData(r1 => { Debug.Assert(r1.Success); }); Service.Instance.GetData2(r2 => { Debug.Assert(r2.Success); });
source share