目前我的應用程序捕獲的未處理異常如下:異常重複無限使用的Rx
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
雖然,當異常就發生這樣的事情(例如):
TimeSpan toExecute = AnyMethod();
Observable.Timer(toExecute).Take(1).Subscribe((r) =>
{
Trace.WriteLine("Subscribe");
throw new Exception(); // simulation..
});
例外不斷重演無限(在調試中)。 雖然在釋放模式或退出的Visual Studio應用程序完成(AppDomain.CurrentDomain.UnhandledException
的標準行爲如何避免或改變這種行爲?
我的目標是隻有一次運行的代碼。獨立的如果發生異常,其中一個要求是它被定時器觸發 Something else ..如果有異常,應該用DispatcherUnhandledException或UnobservedTaskException或類似的方法來處理(這樣可以防止我寫一個try catch對於每次申請和關閉應用)
什麼異常說..我懷疑,如果有一個定時器控件即Observable.Timer(TimeSpan.Zero).Do代碼將在一定數量的間隔中觸發。粘貼Exception請將基本數學任何東西除以0 = 0,但在代碼中將產生DivideByZero異常 – MethodMan
重點是:.Take 1)不被尊重,我更新了我的問題。無論拋出什麼異常 –
Observable.Timer(DateTimeOffset.MinValue,TimeSpan.FromSeconds(1));這會爲你工作嗎? – MethodMan