Exemplo n.º 1
0
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.
                    this._connectionPointContainer = null;
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.
                try
                {
                    if (this._connectionPoint != null)
                    {
                        this._connectionPoint.Unadvise(this._eventSinkHelper.m_dwCookie);
                        Marshal.ReleaseComObject(this._connectionPoint);
                        this._connectionPoint = null;
                        this._eventSinkHelper = null;
                    }

                    if (this._drvCtx != null)
                    {
                        Marshal.ReleaseComObject(this._drvCtx);
                        this._drvCtx = null;
                    }
                }
                catch (Exception)
                {
                }
                finally
                {
                }
            }
            disposed = true;
        }
Exemplo n.º 2
0
        // Methods
        public DrvCtxWrap(IDrvCtx ctx)
        {
            try
            {
                this._drvCtx = ctx;
                this._connectionPointContainer = (IConnectionPointContainer)ctx;

                IConnectionPoint ppCP = null;
                byte[]           b    = new byte[] { 0xe5, 0x26, 0xd6, 0x63, 0x58, 0x20, 0x18, 0x4d, 0xa2, 190, 0x52, 0x3f, 0xf5, 0x3d, 0x44, 0x34 };
                Guid             riid = new Guid(b);

                this._connectionPointContainer.FindConnectionPoint(ref riid, out ppCP);
                this._connectionPoint = (IConnectionPoint)ppCP;

                this._eventSinkHelper = new DrvCtxEventSinkHelper();
                this._eventSinkHelper.m_OnAsyncDataDelegate = new _IDrvCtxEvents_OnAsyncDataEventHandler(this.OnAsyncData);
                this._eventSinkHelper.m_OnNotifyDelegate    = new _IDrvCtxEvents_OnNotifyEventHandler(this.OnNotify);
                this._eventSinkHelper.m_OnStatusDelegate    = new _IDrvCtxEvents_OnStatusEventHandler(this.OnStatus);
                this._eventSinkHelper.m_OnSyncDataDelegate  = new _IDrvCtxEvents_OnSyncDataEventHandler(this.OnSyncData);


                int pdwCookie = 0;
                this._connectionPoint.Advise((object)this._eventSinkHelper, out pdwCookie);
                this._eventSinkHelper.m_dwCookie = pdwCookie;
            }
            catch (Exception theException)
            {
                String errorMessage;
                errorMessage = "Error: ";
                errorMessage = String.Concat(errorMessage, theException.Message);
                errorMessage = String.Concat(errorMessage, " Line: ");
                errorMessage = String.Concat(errorMessage, theException.Source);

                //MessageBox.Show(errorMessage, "Error");

                throw theException;
            }
        }
Exemplo n.º 3
0
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the 
        // runtime from inside the finalizer and you should not reference 
        // other objects. Only unmanaged resources can be disposed.
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed 
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.
                    this._connectionPointContainer = null;
                }

                // Call the appropriate methods to clean up 
                // unmanaged resources here.
                // If disposing is false, 
                // only the following code is executed.
                try
                {
                    if (this._connectionPoint != null)
                    {
                        this._connectionPoint.Unadvise(this._eventSinkHelper.m_dwCookie);
                        Marshal.ReleaseComObject(this._connectionPoint);
                        this._connectionPoint = null;
                        this._eventSinkHelper = null;
                    }

                    if (this._drvCtx != null)
                    {
                        Marshal.ReleaseComObject(this._drvCtx);
                        this._drvCtx = null;
                    }
                }
                catch (Exception)
                {
                }
                finally
                {
                }
            }
            disposed = true;
        }
Exemplo n.º 4
0
        // Methods
        public DrvCtxWrap(IDrvCtx ctx)
        {
            try
            {
                this._drvCtx = ctx;
                this._connectionPointContainer = (IConnectionPointContainer)ctx;

                IConnectionPoint ppCP = null;
                byte[] b = new byte[] { 0xe5, 0x26, 0xd6, 0x63, 0x58, 0x20, 0x18, 0x4d, 0xa2, 190, 0x52, 0x3f, 0xf5, 0x3d, 0x44, 0x34 };
                Guid riid = new Guid(b);

                this._connectionPointContainer.FindConnectionPoint(ref riid, out ppCP);
                this._connectionPoint = (IConnectionPoint)ppCP;

                this._eventSinkHelper = new DrvCtxEventSinkHelper();
                this._eventSinkHelper.m_OnAsyncDataDelegate = new _IDrvCtxEvents_OnAsyncDataEventHandler(this.OnAsyncData);
                this._eventSinkHelper.m_OnNotifyDelegate = new _IDrvCtxEvents_OnNotifyEventHandler(this.OnNotify);
                this._eventSinkHelper.m_OnStatusDelegate = new _IDrvCtxEvents_OnStatusEventHandler(this.OnStatus);
                this._eventSinkHelper.m_OnSyncDataDelegate = new _IDrvCtxEvents_OnSyncDataEventHandler(this.OnSyncData);


                int pdwCookie = 0;
                this._connectionPoint.Advise((object)this._eventSinkHelper, out pdwCookie);
                this._eventSinkHelper.m_dwCookie = pdwCookie;
            }
            catch (Exception theException)
            {
                String errorMessage;
                errorMessage = "Error: ";
                errorMessage = String.Concat(errorMessage, theException.Message);
                errorMessage = String.Concat(errorMessage, " Line: ");
                errorMessage = String.Concat(errorMessage, theException.Source);

                //MessageBox.Show(errorMessage, "Error");

                throw theException;
            }
        }