Skip to content

Instantly share code, notes, and snippets.

@rofr
Created May 8, 2013 14:02
Show Gist options
  • Save rofr/5540634 to your computer and use it in GitHub Desktop.
Save rofr/5540634 to your computer and use it in GitHub Desktop.
This has got to be madly wrong, right?
using (var service = new PollServiceClient())
{
service.PollAsync(request, Poll_Completed);
}
@rofr
Copy link
Author

rofr commented Jun 24, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment