I'm wondering if there is a way to get the result from published event within single method. I have a wcf service and here is the implementation of one of its methods:
public Result DisplayMessage(string message)
{
// some error handling
if(errorOccurred)
{
return new Result { IsError = true, ErrorMessage = "error occurred"}
}
eventAggregator.GetEvent<DisplayMessageEvent>().Publish(new DisplayMessageEventArg(message));
return new Result { IsError = false, ErrorMessage = String.Empty };
}
As you can see my wcf method returns the result which informs the caller if the error occurred or not. I can do some error handling before publish the event but if something happens on the DisplayMessageEvent subscriber side I want also return the result about this. Normally I would do something like DisplayMessageConfirmationEvent and from subscriber send this event to the publisher, but how to do this within single method? So in other words basically what I want to do is to publish the event, wait for the result from the subscriber and return it to the WCF caller. Any ideas?