예제 #1
0
        public async Task SafeFireAndForget_SetDefaultExceptionHandling_WithParams()
        {
            //Arrange
            Exception exception1 = null;
            Exception exception2 = null;

            SafeFireAndForgetExtensions.SetDefaultExceptionHandling(ex => exception1 = ex);

            //Act
            NoParameterDelayedNullReferenceExceptionTask().SafeFireAndForget(onException: ex => exception2 = ex);
            await NoParameterTask();
            await NoParameterTask();

            //Assert
            Assert.IsNotNull(exception1);
            Assert.IsNotNull(exception2);

            SafeFireAndForgetExtensions.SetDefaultExceptionHandling(null);
        }
예제 #2
0
        // Initialization code. Don't use any Avalonia, third-party APIs or any
        // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
        // yet and stuff might break.
        public static void Main(string[] args)
        {
            FixCurrentDirectory();
            if (ProgramBootstrap.TryLaunchUpdaterIfNeeded())
            {
                return;
            }
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            SafeFireAndForgetExtensions.SetDefaultExceptionHandling(Console.WriteLine);
            var app = BuildAvaloniaApp();

            try
            {
                app.StartWithClassicDesktopLifetime(args);
            }
            catch (Exception e)
            {
                FatalErrorHandler.ExceptionOccured(e);
            }
        }
예제 #3
0
 public void AfterEachTest()
 {
     SafeFireAndForgetExtensions.Initialize(false);
     SafeFireAndForgetExtensions.SetDefaultExceptionHandling(null);
 }