예제 #1
0
        /// <summary>
        /// Starts tracking and recording the application diagnostic messages.
        /// </summary>
        /// <returns>
        /// An asynchronous operation.
        /// </returns>
        public async Task StartRecordingDiagnosticsAsync()
        {
            if (this.IsRecordingDiagnostics)
            {
                await Task.CompletedTask;
            }

            this.IsRecordingDiagnostics = true;

            this.EventLogger.WriteInfo("Application diagnostics initialized.");

#if WINDOWS_UWP
            Windows.UI.Xaml.Application.Current.UnhandledException += this.OnAppUnhandledException;
#elif NETSTANDARD2_0 || __ANDROID__ || __IOS__
            AppDomain.CurrentDomain.UnhandledException += this.OnAppUnhandledException;
#endif

#if __ANDROID__
            Android.Runtime.AndroidEnvironment.UnhandledExceptionRaiser += this.OnAndroidAppUnhandledException;

            this.javaExceptionHandler = new UncaughtExceptionHandler(this.OnJavaUncaughtException);
            Java.Lang.Thread.DefaultUncaughtExceptionHandler = this.javaExceptionHandler;
#endif

            TaskScheduler.UnobservedTaskException += this.OnTaskUnobservedException;

            await Task.CompletedTask;
        }
예제 #2
0
        /// <summary>
        /// blast some random strings through the analyzer </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testRandomStrings() throws Exception
        public virtual void testRandomStrings()
        {
            Analyzer a = new PatternAnalyzer(TEST_VERSION_CURRENT, Pattern.compile(","), true, StopAnalyzer.ENGLISH_STOP_WORDS_SET);

            // dodge jre bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7104012
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Thread.UncaughtExceptionHandler savedHandler = Thread.getDefaultUncaughtExceptionHandler();
            UncaughtExceptionHandler savedHandler = Thread.DefaultUncaughtExceptionHandler;

            Thread.DefaultUncaughtExceptionHandler = new UncaughtExceptionHandlerAnonymousInnerClassHelper(this, savedHandler);

            try
            {
                Thread.DefaultUncaughtExceptionHandler;
                checkRandomData(random(), a, 10000 * RANDOM_MULTIPLIER);
            }
            catch (System.IndexOutOfRangeException ex)
            {
                assumeTrue("not failing due to jre bug ", !isJREBug7104012(ex));
                throw ex;   // otherwise rethrow
            }
            finally
            {
                Thread.DefaultUncaughtExceptionHandler = savedHandler;
            }
        }
예제 #3
0
 private void ProcessException(Throwable e)
 {
     if (EventLog.isLoggable(PlatformLogger.Level.FINE))
     {
         EventLog.fine("Processing exception: " + e);
     }
     UncaughtExceptionHandler.UncaughtException(this, e);
 }
예제 #4
0
            public static void InitXamarinExceptionHandler()
            {
                AndroidEnvironment.UnhandledExceptionRaiser += HandleUnhandledExceptionRaiser;
                UncaughtExceptionHandler uncaughtHandler = new UncaughtExceptionHandler();

                uncaughtHandler.UncaughtExceptionHandled                     += OnUncaughtExceptionHandled;
                Java.Lang.Thread.DefaultUncaughtExceptionHandler              = uncaughtHandler;
                AppDomain.CurrentDomain.UnhandledException                   += CurrentDomainUnhandledHandler;
                System.Threading.Tasks.TaskScheduler.UnobservedTaskException += UnobservedTaskExceptionsHandler;
                AsyncSynchronizationContext.ExceptionCaught                  += SyncContextExceptionHandler;
                AsyncSynchronizationContext.Register();
            }
예제 #5
0
 public UncaughtExceptionHandlerAnonymousInnerClassHelper(PatternAnalyzerTest outerInstance, UncaughtExceptionHandler savedHandler)
 {
     this.outerInstance = outerInstance;
     this.savedHandler  = savedHandler;
 }