I am looking for a simple way of calling multiple asynchronous operation with ability to cancel them:
var cancelTask = new ManualResetEvent(false);
IAsyncResult ar = StartAsyncBatch(cancelTask);
int resp = WaitHandler.WaitAny({ar.AsyncWaitHandle, cancelTask});
How I have to build StartAsyncBatch? Should it be derived class
class StartAsyncBatch : IAsyncResult
The brief answer is you can cancel the waiting tasks via corresponding CancellationToken built by CancellationTokenSource. Here is an example.
Things are a little different when you are dealing with a few tasks. Firstly you need to know when cancelling a task, will other tasks continue? If yes, you need to create different cancellation tokens for different tasks and handle the cancellation independently. Otherwise they can share the same cancellation token. Different requirement causes different cancellation handling policy.