using System; using System.Threading; using Caliburn.Metadata; namespace Tests.Caliburn { [Presenter(Rescue = "PresenterRescue")] [TestMetadataProvider] public class TestPresenter { public bool ShouldThrowException = false; public bool TestActionCalled = false; public bool PresenterRescueCalled = false; public bool ActionRescueCalled = false; public bool ActionCallbackCalled = false; public ManualResetEvent WaitHandle = new ManualResetEvent(false); [AsyncAction(Rescue = "ActionRescue", Callback = "ActionCallback")] [TestMetadataProvider] public int TestAction(double input) { TestActionCalled = true; if(ShouldThrowException) throw new Exception(); return (int)(input + 1); } public void PresenterRescue(Exception e) { PresenterRescueCalled = true; WaitHandle.Set(); } public void ActionRescue(Exception e) { ActionRescueCalled = true; WaitHandle.Set(); } public void ActionCallback() { ActionCallbackCalled = true; WaitHandle.Set(); } } }