Example #1
0
 public void Close()
 {
     lock (Lock)
     {
         if (!CanClose())
         {
             return;
         }
         if (_applicationState == ApplicationState.Started)
         {
             ApplicationState = ApplicationState.Closing;
             try
             {
                 OnBeginShutdown();
                 CloseInternal();
                 _assemblyResolver.Dispose();
                 _currentProcess.Dispose();
                 AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException;
                 _shared          = null;
                 ApplicationState = ApplicationState.Closed;
                 OnEndShutdown();
             }
             catch (Exception exception)
             {
                 LoggingProvider.Current.Log(System.Diagnostics.TraceEventType.Critical, exception);
                 throw;
             }
             finally
             {
                 Dispose();
                 DisposableTracker.TraceUndisposedResources();
             }
             if (_processOwner)
             {
                 //TODO: Replace this code with more appropriate process closing
                 ThreadPool.QueueUserWorkItem(c =>
                 {
                     Thread.Sleep(1000);
                     Environment.Exit(0);
                 });
             }
         }
     }
 }
Example #2
0
 protected BaseObject()
 {
     _disposableTracker = new DisposableTracker(this);
     _lock = new object();
 }
 protected RemoteBaseObject(bool trackExpirationTime)
 {
     _disposableTracker = new DisposableTracker(this);
     _lock = new object();
 }
 public AgentLibrary()
 {
     _disposableTracker = new DisposableTracker(this);
     _agentLibrary      = new UnmangedLibrary(LibraryFullName);
 }