Created
May 8, 2013 14:02
-
-
Save rofr/5540634 to your computer and use it in GitHub Desktop.
This has got to be madly wrong, right?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var service = new PollServiceClient()) | |
{ | |
service.PollAsync(request, Poll_Completed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nope, not wrong. This is a pattern recommend by MS.
It looks wrong because the client is disposed immediately after the asynchronous call, and most probably before the callback has been processed. Internally, the service client uses a channel object from a pool of channels. So disposing the client means releasing the channel to pool and the pool or channel itself maintains the state of the call.