Пример #1
0
 private void RemoveEvent(EventSinkMatchDelegate match)
 {
     lock (this) {
         SinkItem prevNode = null;
         SinkItem node     = _sinkHead;
         while (node != null)
         {
             if (match(node.UnkSink))
             {
                 _connectionPoint.Unadvise(node.Cookie);
                 if (prevNode == null)
                 {
                     _sinkHead = node.Next;
                     if (_sinkHead == null)
                     {
                         Marshal.ReleaseComObject(_connectionPoint);
                         _connectionPoint = null;
                     }
                 }
                 else
                 {
                     prevNode.Next = node.Next;
                 }
                 break;
             }
             prevNode = node;
             node     = node.Next;
         }
     }
 }
        public new void Dispose() {
            lock (this) {
                if (_connectionPoint == null)
                    return;

                for (SinkItem node = _sinkHead; node != null; node = node.Next)
                    _connectionPoint.Unadvise(node.Cookie);

                Marshal.ReleaseComObject(_connectionPoint);
                _connectionPoint = null;
                _sinkHead = null;
            }
            GC.SuppressFinalize(this);
        }
        private void AddEvent(EventSinkCreateDelegate assign) {
            lock (this) {
                if (this._connectionPoint == null) {
                    _connectionPointContainer.FindConnectionPoint(ref _riid, out _connectionPoint);
                }

                var eventsSinkHelper = new MSScriptControl_EventSink();
                assign(eventsSinkHelper);

                SinkItem node = new SinkItem();
                node.UnkSink = eventsSinkHelper;
                node.Next = _sinkHead;

                _connectionPoint.Advise(eventsSinkHelper, out node.Cookie);
                _sinkHead = node;
            }
        }
Пример #4
0
        private void AddEvent(EventSinkCreateDelegate assign)
        {
            lock (this) {
                if (this._connectionPoint == null)
                {
                    _connectionPointContainer.FindConnectionPoint(ref _riid, out _connectionPoint);
                }

                var eventsSinkHelper = new MSScriptControl_EventSink();
                assign(eventsSinkHelper);

                SinkItem node = new SinkItem();
                node.UnkSink = eventsSinkHelper;
                node.Next    = _sinkHead;

                _connectionPoint.Advise(eventsSinkHelper, out node.Cookie);
                _sinkHead = node;
            }
        }
Пример #5
0
        public new void Dispose()
        {
            lock (this) {
                if (_connectionPoint == null)
                {
                    return;
                }

                for (SinkItem node = _sinkHead; node != null; node = node.Next)
                {
                    _connectionPoint.Unadvise(node.Cookie);
                }

                Marshal.ReleaseComObject(_connectionPoint);
                _connectionPoint = null;
                _sinkHead        = null;
            }
            GC.SuppressFinalize(this);
        }
 private void RemoveEvent(EventSinkMatchDelegate match) {
     lock (this) {
         SinkItem prevNode = null;
         SinkItem node = _sinkHead;
         while (node != null) {
             if (match(node.UnkSink)) {
                 _connectionPoint.Unadvise(node.Cookie);
                 if (prevNode == null) {
                     _sinkHead = node.Next;
                     if (_sinkHead == null) {
                         Marshal.ReleaseComObject(_connectionPoint);
                         _connectionPoint = null;
                     }
                 } else {
                     prevNode.Next = node.Next;
                 }
                 break;
             }
             prevNode = node;
             node = node.Next;
         }
     }
 }