예제 #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.m_isDisposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    try
                    {
                        // restart the clr if we weren't starting from tinybooter
                        if (m_fRestartClr && m_device.DbgEngine != null &&
                            m_device.DbgEngine.ConnectionSource == Microsoft.SPOT.Debugger.ConnectionSource.TinyBooter
                            )
                        {
                            m_device.Execute(0);
                        }
                    }
                    catch
                    {
                    }
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.
                try
                {
                    MaintainConnection = false;
                }
                catch
                {
                }

                // Note disposing has been done.
                m_isDisposed = true;
            }
        }