I’m developing a Silverlight LOB application.
Due to some required functionality I’ve created a new NewBasePage class for all pages. This class is derived from the Page class. I’ve added couple events and raise them manually.
But I’m stuck with some stuff. I need to check whether all methods that are bound to some event were successfully completed. Is there any way to do this?
New Base Class:
public class NewPageBase : Page
{
public void RefreshData(Action resultAction = null)
{
if (StartRefreshingData != null) StartRefreshingData(this, null);
if (resultAction != null) resultAction();
}
public event EventHandler StartRefreshingData;
}
Xaml:
<newbase:NewBasePage ...>
...
<i:Interraction.Triggers>
<i:EventTrigger EventName="StartRefreshingData">
<i:InvokeCommandAction Command="{StaticResource someCommandFromViewModel}"/>
</i:EventTrigger>
</i:Interraction.Triggers>
</newbase:NewBasePage>
If you want to know if any event handler failed to do his work you can either throw an Exception or provide a custom EventArgs type which tracks if any event handler failed.
Usage:
And, as already mentioned in my comment above, once the invokation of the event is over, you can be sure that there is no attached event handler processed anymore.