tags:

views:

168

answers:

3

For each class I create a new instance of the web service proxy.

Main Form:

services services = new services();
services.doStuff();

New Form/Window from the Main Form:

services services = new services();
services.doStuff();

Should I be passing the first instance from the Main GUI? or does it even matter...

frmWindow window = new frmWindow(services);
A: 

That entirely depends on the design of your class. Does it make sense to have multiple 'service' objects?

Also, is an object of your 'service' class expensive to create and maintain? I think we need a lot more info here to give you a useful answer.

Ed Swangren
+1  A: 

It's up to you.

If I need that web proxy or anything only have one instance, need to provide a global as an access point to the instance as singleton object.

Anwar Chandra
singleton sounds good, looking into it.
Shawn
+1  A: 

Service proxy objects are very cheap for both asmx and WCF (you didn't specify which one you're using)- just create them when you need them and throw them away. The most expensive part is setting up the network connection to the target server, which is usually pooled and cached anyway. Don't kill yourself caching and passing around proxies- it's a microperf optimization that's rarely worth the complexity.

nitzmahone
I am using ASMX. I wanted to hear that they were pooled and cached so this helps out. The answers here lead me in the direction I will be implementing fail over. So thanks.
Shawn