I am just curious to know that why the return type of an asynchronous call in c# is IAsynceResult ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What else would it be? It can’t be the “final” result of the call, as that won’t be known yet. Basically it’s a value representing the asynchronous call, so that you can later determine whether it’s completed, what the result was etc.
It’s a shame it’s not generic (in the result type) for non-void async calls, but that’s due to the legacy of .NET 1 not supporting generics.
EDIT: I nearly mentioned
Task<T>originally. The trouble is, there are a lot of places where the method is already declared to returnIAsyncResult, and you can’t just go changing APIs left, right and centre. I do occasionally wonder how much cleaner .NET would be if MS had waited for generics before releasing. Of course that sort of argument is always applicable, but for generics it’s particularly important IMO.