Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF and Silverlight close guidance

I am reading a lot of conflicting information about how and when to close a WCF service.

Some people say you don't need to.

Some people say in the same place where you make the Async call

Some people say in the completed method.

Can someone point me to a place where microsoft actually says how to use this method? Also when do you call it?

like image 215
zachary Avatar asked Nov 15 '22 02:11

zachary


1 Answers

Are you referring to client or service side closing For client closing this is the recommended pattern - http://blogs.msdn.com/b/drnick/archive/2007/05/04/the-try-catch-abort-pattern.aspx

For services you can close the service host. For eg. in the self hosted service say using a windows NT Service, on Service shutdown you want to close the host so that clean up like un-registering ports etc. happen gracefully.

If you want to the try/catch/abort patten works for invocation and also for close. So you can provide a timeout and if you get a timeout exception, abort the instance.

like image 130
Sajay Avatar answered Dec 07 '22 23:12

Sajay