tags:

views:

212

answers:

1

I'm working on an application that uses WPF and WCF. As it stands now, for each WPF page, a WCF connection is created for that page to use. Is this good practice? Or should I create a Singleton object to contain a WCF connection that's passed around to my pages as needed?

Thanks!

+2  A: 

If the connection parameters and various authorization aspects are the same throughout the app, the i'd definitely suggest to use a single connection. Creating different connections might have sense probably when your pages are like browser tabs - they connect to different servers and are basically independent.

Moreover, consider not using the WCF connection in you UI logic at all, create some middle-layer, that gets data via WCF and make your UI independent of where actually the data comes from technically. Your UI logic should work with objects provided by that middle (business) layer.

arconaut