當前位置: 首頁>>代碼示例>>C#>>正文


C# Threading.DispatcherUnhandledExceptionEventArgs類代碼示例

本文整理匯總了C#中System.Windows.Threading.DispatcherUnhandledExceptionEventArgs的典型用法代碼示例。如果您正苦於以下問題:C# DispatcherUnhandledExceptionEventArgs類的具體用法?C# DispatcherUnhandledExceptionEventArgs怎麽用?C# DispatcherUnhandledExceptionEventArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DispatcherUnhandledExceptionEventArgs類屬於System.Windows.Threading命名空間,在下文中一共展示了DispatcherUnhandledExceptionEventArgs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: App_DispatcherUnhandledException

		private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
		{
#if (!DEBUG)
			var date = DateTime.Now;
			var fileName = "Crash Reports\\"
			               + string.Format("Crash report {0}{1}{2}-{3}{4}", date.Day, date.Month, date.Year, date.Hour, date.Minute);

			if(!Directory.Exists("Crash Reports"))
				Directory.CreateDirectory("Crash Reports");

			using(var sr = new StreamWriter(fileName + ".txt", true))
			{
				sr.WriteLine("########## " + DateTime.Now + " ##########");
				sr.WriteLine(e.Exception);
				sr.WriteLine(Core.MainWindow.Options.OptionsTrackerLogging.TextBoxLog.Text);
			}

			MessageBox.Show(
			                "A crash report file was created at:\n\"" + Environment.CurrentDirectory + "\\" + fileName
			                + ".txt\"\n\nPlease \na) create an issue on github (https://github.com/Epix37/Hearthstone-Deck-Tracker) \nor \nb) send me an email ([email protected]).\n\nPlease include the generated crash report(s) and a short explanation of what you were doing before the crash.",
			                "Oops! Something went wrong.", MessageBoxButton.OK, MessageBoxImage.Error);
			e.Handled = true;
			Shutdown();
#endif
		}
開發者ID:kiizoo,項目名稱:Hearthstone-Deck-Tracker,代碼行數:25,代碼來源:App.xaml.cs

示例2: OnUnhandledException

 private static void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     //ReportUnhandledException(e.Exception);
     //throw e.Exception;
     AppServices.Dialog.ShowWarning(e.Exception.Message);
     e.Handled = true;
 }
開發者ID:kubaszostak,項目名稱:KSz.Shared,代碼行數:7,代碼來源:WpfAppUIService.cs

示例3: OnDispatcherUnhandledException

        private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            LogService.RecordException(sender, e.Exception);

            e.Handled = true;
            Application.Current.Shutdown();
        }
開發者ID:modulexcite,項目名稱:WlanProfileViewer,代碼行數:7,代碼來源:App.xaml.cs

示例4: App_DispatcherUnhandledException

        private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            _isSaved = true;
            try
            {
                MainTokenSource.Cancel();
            }
            catch
            {
            }
            finally
            {
                MainTokenSource.Dispose();
            }

            #if !DEBUG
            if (e.Exception == null)
            {
                Application.Current.Shutdown();
                return;
            }
            //Log.Logger.Default.AddLogItem(new Log.LogItem(e.Exception));
            MessageBox.Show("發生內部錯誤\n\n" + e.Exception.ToString(), App.NAME);
            e.Handled = true;
            Application.Current.Shutdown();
            #endif
        }
開發者ID:Provence,項目名稱:MiniTwitter-Mod,代碼行數:27,代碼來源:App.xaml.cs

示例5: Application_DispatcherUnhandledException

        void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.Message, CoC.Bot.Properties.Resources.AppName, MessageBoxButton.OK, MessageBoxImage.Exclamation);

            // Prevent default unhandled exception processing
            e.Handled = true;
        }
開發者ID:hasantemel,項目名稱:Coc-bot-Csharp,代碼行數:7,代碼來源:App.xaml.cs

示例6: My_DispatcherUnhandledException

 private void My_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     if (e != null)
     {
         e.Handled = this.ShowException(e.Exception);
     }
 }
開發者ID:QuocHuy7a10,項目名稱:Arianrhod,代碼行數:7,代碼來源:App.xaml.cs

示例7: OnDispatcherUnhandledException

 private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     Logger.Log.Error("Unhandled exception", e.Exception);
     MessagingService.ShowErrorMessage(Common.Resources.Strings.Resources.UnhandledException,
         e.Exception.ToString(), false);
     e.Handled = true;
 }
開發者ID:nathanashton,項目名稱:Bookie,代碼行數:7,代碼來源:App.xaml.cs

示例8: ShowUnhandeledException

        private void ShowUnhandeledException(DispatcherUnhandledExceptionEventArgs e)
        {
            e.Handled = true;

            string errorMessage =
                string.Format(
                    "An application error occurred.\nPlease check whether your data is correct and repeat the action. If this error occurs again there seems to be a more serious malfunction in the application, and you better close it.\n\nError:{0}\n\nDo you want to continue?\n(if you click Yes you will continue with your work, if you click No the application will close)",

                    e.Exception.Message + (e.Exception.InnerException != null
                        ? "\n" +
                          e.Exception.InnerException.Message
                        : null));

            Trace.TraceError(errorMessage);
            Trace.TraceError("Stack Trace " + e.Exception.StackTrace);
            Trace.TraceError("Source " + e.Exception.Source);
            Trace.TraceError("Inner Exception3 " + e.Exception.InnerException);

            //if (
            //    MessageBox.Show(errorMessage, "Application Error", MessageBoxButton.YesNoCancel, MessageBoxImage.Error, MessageBoxResult.No) ==
            //    MessageBoxResult.Yes)
            {
                {

                    Application.Current.Shutdown();
                }
            }
        }
開發者ID:tenacious,項目名稱:Auto.Squirrel,代碼行數:28,代碼來源:App.xaml.cs

示例9: App_DispatcherUnhandledException

        private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            #if(DEBUG)
            //Just so resharper codecleanup does not remove using system and system.io when in debug
            if(File.Exists("HearthstoneDeckTracker.exe"))
                Console.WriteLine("Ignore this");
            #endif
            #if (!DEBUG)
            var date = DateTime.Now;
            var fileName = "Crash Reports/" + string.Format("Crash report {0}{1}{2}-{3}{4}", date.Day, date.Month, date.Year, date.Hour, date.Minute);

            if (!Directory.Exists("Crash Reports"))
                Directory.CreateDirectory("Crash Reports");

            using (var sr = new StreamWriter(fileName + ".txt", true))
            {
                sr.WriteLine("########## " + DateTime.Now + " ##########");
                sr.WriteLine(e.Exception);
            }

            MessageBox.Show("Something went wrong.\nA crash report file was created at:\n\"" + Environment.CurrentDirectory + "\\" + fileName + "\"\nPlease create an issue in the github, message me on reddit (/u/tnx) or send this file to [email protected], with a short explanation of what you were doing before the crash.", "Oops!", MessageBoxButton.OK, MessageBoxImage.Error);
            e.Handled = true;
            Shutdown();
            #endif
        }
開發者ID:kkcosmo,項目名稱:Hearthstone-Deck-Tracker,代碼行數:25,代碼來源:App.xaml.cs

示例10: OnDispatcherUnhandledException

		protected override void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
		{
			logger.Error(e.Exception);
			e.Handled = true;

			base.OnDispatcherUnhandledException(sender, e);
		}
開發者ID:matteomigliore,項目名稱:HSDK,代碼行數:7,代碼來源:TestExceptionHandler.cs

示例11: Application_DispatcherUnhandledException

 private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     if (ignore.IsChecked != null && ignore.IsChecked.Value)
     {
         e.Handled = true;
     }
 }
開發者ID:shivercube,項目名稱:C-Sharp_Application_Classes,代碼行數:7,代碼來源:Window1.xaml.cs

示例12: App_OnUnhandledException

        private void App_OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            const string applicationTitle = "Music Manager";
            const string logMessage = "An unhandled exception occurred";

            string userMessage = string.Format("Oops!!! '{0}' ran into a problem. "
                                    + "The error details have been saved to the local log file.",
                                    applicationTitle);
            string userMsgIfErrorHandlingFails = string.Format("Oops!!! '{0}' ran into a problem. "
                                    + "Poosibly an error occured while bootstrapping the application.",
                                    applicationTitle);
            try
            {
                var errorHandler = _container.Resolve<IErrorHandler>();
                errorHandler.HandleError(e.Exception, logMessage, userMessage);
            }
            catch (Exception exception)
            {
                var logger = _container.Resolve<ILogger>();
                logger.LogError(logMessage, exception);

                var promptService = new PromptService(applicationTitle);
                promptService.ShowError(userMsgIfErrorHandlingFails);
            }

            e.Handled = true;
        }
開發者ID:hemantksingh,項目名稱:MusicManager,代碼行數:27,代碼來源:App.xaml.cs

示例13: OnDispatcherUnhandledException

 private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     System.Windows.MessageBox.Show("Uncaught exception in Auremo.\n" +
                                    "Please take a screenshot of this message and send it to the developer.\n\n" +
                                    e.Exception.ToString(),
                                    "Auremo has crashed!");
 }
開發者ID:paukr,項目名稱:auremo,代碼行數:7,代碼來源:App.xaml.cs

示例14: AppDispatcherUnhandledException

        void AppDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            //do whatever you need to do with the exception
            MessageBox.Show(e.Exception.Message);

            e.Handled = true;
        }
開發者ID:jackyying1130,項目名稱:POC,代碼行數:7,代碼來源:App.xaml.cs

示例15: appDispatcherUnhandledException

        private void appDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            new ExceptionLogger().LogExceptionToFile(e.Exception, AppMessenger.LogFile);
            e.Handled = true;

            addException(e.Exception);
        }
開發者ID:yao-yi,項目名稱:DNTProfiler,代碼行數:7,代碼來源:MainViewModel.cs


注:本文中的System.Windows.Threading.DispatcherUnhandledExceptionEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。