Beispiel #1
0
        public static void SetHandler(IUnhandledExceptionHandler handler)
        {
            handler.ThrowIfNull(nameof(handler));

            Handlers.Add(handler);

            AppDomain.CurrentDomain.UnhandledException += handler.UnhandledExceptionEventHandler;
        }
Beispiel #2
0
 public GameServer(
     [NotNull] IUnhandledExceptionHandler unhandledExceptionHandler)
 {
     if (unhandledExceptionHandler == null)
     {
         throw new ArgumentNullException("unhandledExceptionHandler");
     }
     _serviceLock = new object();
     _unhandledExceptionHandler = unhandledExceptionHandler;
 }
Beispiel #3
0
 /// <summary>
 ///     Creates a new instance.
 /// </summary>
 public CommandLineLifetime(IApplicationLifetime applicationLifetime,
                            ICommandLineService cliService,
                            IConsole console,
                            IUnhandledExceptionHandler unhandledExceptionHandler = null)
 {
     _applicationLifetime       = applicationLifetime;
     _cliService                = cliService;
     _console                   = console;
     _unhandledExceptionHandler = unhandledExceptionHandler;
 }
 public void RunAsync(Action action, IUnhandledExceptionHandler handler)
 {
     if (handler != null)
     {
         _context.Post((s) => { try { action.Invoke(); } catch (Exception e) { handler.Handle(e); } }, null);
     }
     else
     {
         _context.Post((s) => action.Invoke(), null);
     }
 }
 internal void Add(IUnhandledExceptionHandler handler)
 {
     lock (this.m_locker)
     {
         this.m_handlers.Add(handler);
         if (!this.m_isHandlerSet)
         {
             AppDomain.CurrentDomain.UnhandledException += this.OnUnhandledException;
             AmUnhandledExceptionHandler.Tracer.TraceDebug((long)this.GetHashCode(), "AmUnhandledExceptionHandler: Unhandled exception handler is set.");
             this.m_isHandlerSet = true;
         }
     }
 }
 internal void Remove(IUnhandledExceptionHandler handler)
 {
     lock (this.m_locker)
     {
         if (handler != null)
         {
             if (this.m_handlers.Count > 0)
             {
                 this.m_handlers.Remove(handler);
             }
         }
         else
         {
             this.m_handlers.Clear();
         }
         if (this.m_handlers.Count == 0 && this.m_isHandlerSet)
         {
             AppDomain.CurrentDomain.UnhandledException -= this.OnUnhandledException;
             AmUnhandledExceptionHandler.Tracer.TraceDebug((long)this.GetHashCode(), "AmUnhandledExceptionHandler: Unhandled exception handler is removed.");
             this.m_isHandlerSet = false;
         }
     }
 }