Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - WCF; closing client

 
 
Old 01-15-2007   #1 (permalink)
Marc Gravell


 
 

WCF; closing client

General question; WCF clients - do these (broadly) pool? My assumption
is "no".

Specifically, if I am expecting to perform additional requests
shortly, should I close the client and re-obtain when needed, or leave
it open and re-use it? I would lean towards the latter, unlike (for
instance) SqlConnections which I would generally close/dispose and let
the pool worry about it...

Even if it doesn't pool, is the overhead significant in closing each
time versus re-using?

Cheers,

Marc




My System SpecsSystem Spec
Old 01-15-2007   #2 (permalink)
Marc Gravell


 
 

Re: WCF; closing client

additional; relating in particular to IIS-hosted "svc" style services,
using transport encryption and without any security negotiations [for
compatibility with existing systems, security handled via bespoke
extensions / headers]

Marc


My System SpecsSystem Spec
Old 01-17-2007   #3 (permalink)
Joerg Jooss


 
 

Re: WCF; closing client

Thus wrote Marc,

> General question; WCF clients - do these (broadly) pool? My assumption
> is "no".


That's right. Closing the client prematurely can also terminate a session
or a secure conversation, which is quite expensive to establish.

> Specifically, if I am expecting to perform additional requests
> shortly, should I close the client and re-obtain when needed, or leave
> it open and re-use it? I would lean towards the latter, unlike (for
> instance) SqlConnections which I would generally close/dispose and let
> the pool worry about it...


In this scenario (and especially when using more expensive binding features)
you should reuse your clients, but also monitor their states closely using
the lifecycle events of ClientBase<T>. Once a client has faulted, call Abort()
on it to avoid leaking resources, and replace it with a fresh instance. See
http://msdn2.microsoft.com/en-us/library/ms734653.aspx for further details.

Cheers,
--
Joerg Jooss
news-reply@joergjooss.de


My System SpecsSystem Spec
Old 01-17-2007   #4 (permalink)
Marc Gravell


 
 

Re: WCF; closing client

Thankyou - I think that confirms my thoughts... unfortunately the
"always close" warning on generated classes doesn't make this very
clear ;-p

Cheers,

Marc


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
dat keeps closing ie8 Vista security
Windows Mail keeps closing because DEP is closing for security Vista mail
Closing Down General Discussion
Closing WLM Live Mail
closing lid Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46