Reputation: 31055
I have a web service that instantiates an object, subscribes to an event on that object, and then calls a function on the object which will lead to the event being fired. Is there a way to wait for the event to fire so I can get the results from the EventArgs in order to pass those results as the results of the web service?
Upvotes: 0
Views: 126
Reputation: 6109
You will need some kind of synchronization primitive associated with the event (such as a ManualResetEventSlim) that gets signalled in the event handler. Then your request thread can wait on the event and collect the results after the event has occurred and generate the response
However, a more natural model may be to create the service as an asynchronous service and only complete the processing when the async operation completes - I created a sample of this a while back
Upvotes: 1