tags:

views:

134

answers:

1

I'm hosting a WCF service inside a winform app. I want to monitor when somebody calls the service to a textbox on the form like:

2:23 Method X called params(x, y)
2:24 Method Y called params(z)

I am using a service host for WCF and inside my concrete class I have created some delegates and events. I just cant seem to wire the events up because my object is of type ServiceHost not my object.

Any help

+2  A: 

there are few ways. You can make those events static.

or

you can make your service a singleton then you can say

MyService service =new MyService();
service.EventA += EventHandeler();
new ServiceHost(service).Open();

In addition when your web service updates UI elements you may need to make sure the right thread does the work. That applies to WPF and winforms. Synchronization Contexts in WCF

Vitalik
Thanks Vitalik, passing in an instance of the class to WCF to wire up to is exactly what I was looking for!
Steven