I am trying to port some existing APM calls ( BeginX , EndX ) to Tasks in order to get all the useful benefits from them. Unfortunately, our methods are unconventional and use the out parameters and therefore cannot use the standard FromAsync method, where you give it both the start and end delegates and allow it to easily transfer it.
This article describes an alternative: an overload that accepts IAsyncResult and only requires an end callback. They take the IAsyncResult handle, then wait for completion, then call the delegate that you passed.
It seemed fine, but then I read another article on APM call wrapping in tasks . He also mentions that IAsyncResult overloading IAsyncResult not as efficient as other methods. It seems to me that this means that the callback is not used to report the completion of the method. This means that they must use AsyncWaitHandle or IsCompleted . Which one do they use? How high is the performance?
If this is done by polling, it means that the callback may not appear immediately, and they should carefully check it during the whole call. If they have AsyncWaitHandle , they have another thread that sits and waits for the result, which completely hits the point of using the asynchronous method for me.
Does anyone know what they are doing, and how serious is this performance hit?
source share