Component

public class Component : MarshalByRefObject, IComponent
{
    ~Component()
    {
        Dispose(false);
    }


    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed")]
    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    protected virtual void Dispose(bool disposing)
    {
        if (disposing)
        {
            lock (this)
            {
                if (site != null && site.Container != null)
                {
                    site.Container.Remove(this);
                }
                if (events != null)
                {
                    EventHandler handler = (EventHandler)events[EventDisposed];
                    if (handler != null) handler(this, EventArgs.Empty);
                }
            }
        }
    }
}

 

posted @ 2016-11-03 22:19  茗::流  阅读(164)  评论(0)    收藏  举报
如有雷同,纯属参考。如有侵犯你的版权,请联系我。