packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/Direct2D/D2DShapes/D2DShapesControl.cs
/// <summary>
/// Dispose of resources (IDisposable implementation)
/// </summary>
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
Dispose of resources (IDisposable implementation)
Dispose of resources ( IDisposable implementation )
protected override void Dispose(bool disposing)
        {
            if (disposing && !disposed)
            {
                lock (renderSyncObject)
                {
                    render = null;
                    lock (sharedSyncObject)
                    {
                        if (sharedD2DFactory != null && d2DFactory == sharedD2DFactory)
                            sharedRefCount--;
                        if (d2DFactory != null && d2DFactory != sharedD2DFactory)
                            d2DFactory.Dispose();
                        d2DFactory = null;
                        if (dwriteFactory != null && dwriteFactory != sharedDwriteFactory)
                            dwriteFactory.Dispose();
                        dwriteFactory = null;
                        if (wicFactory != null && wicFactory != sharedWicFactory)
                            wicFactory.Dispose();
                        wicFactory = null;
                        if (sharedRefCount == 0)
                        {
                            if (sharedD2DFactory != null)
                                sharedD2DFactory.Dispose();
                            sharedD2DFactory = null;
                            if (sharedDwriteFactory != null)
                                sharedDwriteFactory.Dispose();
                            sharedDwriteFactory = null;
                            if (sharedWicFactory != null)
                                sharedWicFactory.Dispose();
                            sharedWicFactory = null;
                        }
                    }
                    foreach (DrawingShape shape in drawingShapes)
                    {
                        shape.Dispose();
                    }
                    if (bitmap != null)
                        bitmap.Dispose();
                    bitmap = null;
                    if (dcRenderTarget != null)
                        dcRenderTarget.Dispose();
                    dcRenderTarget = null;
                    if (bitmapRenderTarget != null)
                        bitmapRenderTarget.Dispose();
                    bitmapRenderTarget = null;
                    if (hwndRenderTarget != null)
                        hwndRenderTarget.Dispose();
                    hwndRenderTarget = null;
                    disposed = true;
                }
            }
            base.Dispose(disposing);
        }
protected override void Dispose ( bool disposing ) { if ( disposing && ! disposed ) { lock ( renderSyncObject ) { render = null ; lock ( sharedSyncObject ) { if ( sharedD2DFactory != null && d2DFactory == sharedD2DFactory ) sharedRefCount -- ; if ( d2DFactory != null && d2DFactory != sharedD2DFactory ) d2DFactory . Dispose ( ) ; d2DFactory = null ; if ( dwriteFactory != null && dwriteFactory != sharedDwriteFactory ) dwriteFactory . Dispose ( ) ; dwriteFactory = null ; if ( wicFactory != null && wicFactory != sharedWicFactory ) wicFactory . Dispose ( ) ; wicFactory = null ; if ( sharedRefCount == 0 ) { if ( sharedD2DFactory != null ) sharedD2DFactory . Dispose ( ) ; sharedD2DFactory = null ; if ( sharedDwriteFactory != null ) sharedDwriteFactory . Dispose ( ) ; sharedDwriteFactory = null ; if ( sharedWicFactory != null ) sharedWicFactory . Dispose ( ) ; sharedWicFactory = null ; } } foreach ( DrawingShape shape in drawingShapes ) { shape . Dispose ( ) ; } if ( bitmap != null ) bitmap . Dispose ( ) ; bitmap = null ; if ( dcRenderTarget != null ) dcRenderTarget . Dispose ( ) ; dcRenderTarget = null ; if ( bitmapRenderTarget != null ) bitmapRenderTarget . Dispose ( ) ; bitmapRenderTarget = null ; if ( hwndRenderTarget != null ) hwndRenderTarget . Dispose ( ) ; hwndRenderTarget = null ; disposed = true ; } } base . Dispose ( disposing ) ; }
Dispose of resources (IDisposable implementation)
Dispose of resources ( IDisposable implementation )
disposing
bool
true to release both managed and unmanaged resources; false to release only unmanaged resources.
true to release both managed and unmanaged resources ; false to release only unmanaged resources .