Prism is notified that the processed event has been processed.

I am posting an event (I am using Microsoft.Practices.Prism.Events). This event will be processed elsewhere. Then I want to wait until this is processed (I don’t care where and by whom), before continuing with the code, I want the handler to put some status in my arg argument, so I can use this status (for example, successful printing or failed to print) before deciding what to do next.

Should I just start the thread and check for arg.Status (which I can configure for subscribers during processing)?

Or alternatively, if the subscriber raises another event informing that the publication is completed or something else?

public void Execute(object parameter)
{
    var arg = new PrintCustomerAccountSummaryReportRequestedEventArgument  { Customer = _viewModel.Customer, StartDate = _viewModel.ReportStartDate, EndDate = _viewModel.ReportEndDate };
    EventManager.Instance.GetEvent<PrintCustomerAccountSummaryReportRequestedEvent>().Publish(arg);
    // Wait until something has handled the event
    // then continue on and execute code.
}
+4
1

, , . PrintResult , .

PrintCustomerAccountSummaryReportRequestedEvent , , PrintResult, , :

public Publisher(...)
{
   ...
   PrintResultEvent printResultEvent = this.eventAggregator.GetEvent<PrintResultEvent>();
   printResultEvent.Subscribe(PrintResultEventHandler);
}

public void Execute(object parameter)
{
    var arg = new PrintCustomerAccountSummaryReportRequestedEventArgument  { Customer = _viewModel.Customer, StartDate = _viewModel.ReportStartDate, EndDate = _viewModel.ReportEndDate };
    EventManager.Instance.GetEvent<PrintCustomerAccountSummaryReportRequestedEvent>().Publish(arg);
    // Wait until something has handled the event
    // then continue on and execute code. Result will be handled in following EventHandler.
}

private void PrintResultEventHandler(PrintCustomerAccountSummaryReportRequestedEventArgument result)
{
   // Get print result and finish job accordingly.
}

, ,

.

0

All Articles