Exemplo n.º 1
0
        private void InternalStopLocalServer()
        {
            ComDebug.ReportInfo("Stop local server");

            if (null != _embeddedComObject)
            {
                _embeddedComObject.Dispose();
                _embeddedComObject = null;
            }

            foreach (var co in _linkedDocumentsComObjects.Values)
            {
                co.Dispose();
            }
            _linkedDocumentsComObjects.Clear();

            if (null != _fileComObject)
            {
                _fileComObject.Dispose();
                _fileComObject = null;
            }

            if (null != _classFactoryOfDocumentComObject)
            {
                _classFactoryOfDocumentComObject.RevokeClassObject();
                ComDebug.ReportInfo("{0}.StopLocalServer:{1} Revoked.", GetType().Name, _classFactoryOfDocumentComObject.GetType().Name);
                _classFactoryOfDocumentComObject = null;
            }

            if (null != _classFactoryOfFileComObject)
            {
                _classFactoryOfFileComObject.RevokeClassObject();
                ComDebug.ReportInfo("{0}.StopLocalServer:{1} Revoked.", GetType().Name, _classFactoryOfFileComObject.GetType().Name);
                _classFactoryOfFileComObject = null;
            }

            if (null != _garbageCollector)
            {
                // Now stop the Garbage Collector thread.
                _garbageCollector.StopThread();
                _garbageCollector.WaitForThreadToStop();
                _garbageCollector = null;
                ComDebug.ReportInfo("StopLocalServer: GarbageCollector thread stopped.");
            }

            IsActive = false;
        }