/// <summary> /// Cleans up the COM object references. /// </summary> /// <param name="disposing"> /// <see langword="true"/> if this was called from the /// <see cref="IDisposable"/> interface. /// </param> private void Dispose(bool disposing) { lock (this) { if (null != _eventSink) { _eventSink.Dispose(); _eventSink = null; } if (null != _connectionPoint) { while (Marshal.ReleaseComObject(_connectionPoint) > 0) { ; } _connectionPoint = null; } if (null != _connectionPointContainer) { while (Marshal.ReleaseComObject(_connectionPointContainer) > 0) { ; } _connectionPointContainer = null; } } }
/// <summary> /// Initialize the event sink. /// </summary> private void Initialize() { if (null == _connectionPointContainer) { throw new ObjectDisposedException("ComEventProvider"); } UCOMIConnectionPoint connectionPoint; Guid pointGuid = _connectionPointGuid; _connectionPointContainer.FindConnectionPoint(ref pointGuid, out connectionPoint); _connectionPoint = connectionPoint; _eventSink = (ComEventSink)Activator.CreateInstance(_eventSinkType); _eventSink.Connect(_connectionPoint); _eventSink.Owner = _owner; }