LEADTOOLS (Leadtools assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
IsDisposed Property
See Also 
Leadtools Namespace > RasterImage Class : IsDisposed Property



Gets a value indicating whether the RasterImage object has been disposed of. Supported in Silverlight, Windows Phone 7

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property IsDisposed As Boolean
Visual Basic (Usage)Copy Code
Dim instance As RasterImage
Dim value As Boolean
 
value = instance.IsDisposed
C# 
public bool IsDisposed {get;}
C++/CLI 
public:
property bool IsDisposed {
   bool get();
}

Property Value

true if the RasterImage object has been disposed of; otherwise, false.

Example

This example will show the use of the IsDisposed property of a RasterImage object.

Visual BasicCopy Code
Public Sub IsDisposedTest()
   ' Create a RasterImage objects
   Dim image As New RasterImage( _
      RasterMemoryFlags.Conventional, _
      100, _
      100, _
      24, _
      RasterByteOrder.Bgr, _
      RasterViewPerspective.TopLeft, _
      Nothing, _
      IntPtr.Zero, _
      0)
   ' Check the IsDisposed property, should be false
   Debug.Assert(Not image.IsDisposed)
   MessageBox.Show("IsDisposed = " + image.IsDisposed.ToString())

   ' Now dispose the image
   image.Dispose()

   ' Re-check the IsDisposed property, should be true
   Debug.Assert(image.IsDisposed)
   MessageBox.Show("IsDisposed = " + image.IsDisposed.ToString())
End Sub
C#Copy Code
public void IsDisposedTest()
{
   // Create a RasterImage objects
   RasterImage image = new RasterImage(
      RasterMemoryFlags.Conventional,
      100,
      100,
      24,
      RasterByteOrder.Bgr,
      RasterViewPerspective.TopLeft,
      null,
      IntPtr.Zero,
      0);

   // Check the IsDisposed property, should be false
   Debug.Assert(!image.IsDisposed);
   MessageBox.Show("IsDisposed = " + image.IsDisposed.ToString());

   // Now dispose the image
   image.Dispose();

   // Re-check the IsDisposed property, should be true
   Debug.Assert(image.IsDisposed);
   MessageBox.Show("IsDisposed = " + image.IsDisposed.ToString());
}
SilverlightCSharpCopy Code
public void IsDisposedTest()
{
   // Create a RasterImage objects
   RasterImage image = new RasterImage(
      RasterMemoryFlags.Conventional,
      100,
      100,
      24,
      RasterByteOrder.Bgr,
      RasterViewPerspective.TopLeft,
      null,
      null,
      0);
   // Check the IsDisposed property, should be false
   Debug.Assert(!image.IsDisposed);
   Debug.WriteLine("IsDisposed = " + image.IsDisposed.ToString());

   // Now dispose the image
   image.Dispose();

   // Re-check the IsDisposed property, should be true
   Debug.Assert(image.IsDisposed);
   Debug.WriteLine("IsDisposed = " + image.IsDisposed.ToString());
}
SilverlightVBCopy Code
Public Sub IsDisposedTest()
   ' Create a RasterImage objects
   Dim image As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, 100, 100, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, Nothing, Nothing, 0)
   ' Check the IsDisposed property, should be false
   Debug.Assert((Not image.IsDisposed))
   Debug.WriteLine("IsDisposed = " & image.IsDisposed.ToString())

   ' Now dispose the image
   image.Dispose()

   ' Re-check the IsDisposed property, should be true
   Debug.Assert(image.IsDisposed)
   Debug.WriteLine("IsDisposed = " & image.IsDisposed.ToString())
End Sub

Remarks

When this property returns true, the RasterImage object is disposed of and can no longer be referenced as a valid object. Even though the instance of an object is disposed of, it is still maintained in memory until it is removed from memory through garbage collection. When an object is disposed, you should not check any other properties or call any other methods in the control or an System.NullReferenceException error will occur.

If it is required to track when a RasterImage object is disposed, use the Disposed event.

The RasterImage class implements the System.IDisposable interface, it is recommended that you follow the standard .NET dispose pattern when using the RasterImage class. For more information, refer to the System.IDisposable interface documentation in MSDN.

Requirements

Target Platforms: Silverlight, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only), Windows Phone 7

See Also