System.Data.SQLite
Check-in [b8212344a0]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add custom locking semantics for the CriticalHandle derived classes when compiled for the .NET Compact Framework.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b8212344a0dc6e3769d8d81728c73702547f4c41
User & Date: mistachkin 2012-10-04 11:21:36
Context
2012-10-05
00:17
More refinements to disposal locking semantics on the .NET Compact Framework. check-in: ac5f4cc084 user: mistachkin tags: trunk
2012-10-04
11:21
Add custom locking semantics for the CriticalHandle derived classes when compiled for the .NET Compact Framework. check-in: b8212344a0 user: mistachkin tags: trunk
2012-09-24
20:48
Doc updates for Visual Studio 2012. check-in: e7339793f8 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/UnsafeNativeMethods.cs.

  1439   1439         get;
  1440   1440       }
  1441   1441   
  1442   1442     }
  1443   1443   
  1444   1444   #endif
  1445   1445   
  1446         -  // Handles the unmanaged database pointer, and provides finalization support for it.
  1447         -  internal class SQLiteConnectionHandle : CriticalHandle
  1448         -  {
  1449         -    public static implicit operator IntPtr(SQLiteConnectionHandle db)
         1446  +    ///////////////////////////////////////////////////////////////////////////
         1447  +
         1448  +    #region SQLiteConnectionHandle Class
         1449  +    // Handles the unmanaged database pointer, and provides finalization
         1450  +    // support for it.
         1451  +    internal class SQLiteConnectionHandle : CriticalHandle
  1450   1452       {
  1451         -      return (db != null) ? db.handle : IntPtr.Zero;
  1452         -    }
  1453         -
  1454         -    internal SQLiteConnectionHandle(IntPtr db)
  1455         -      : this()
  1456         -    {
  1457         -      SetHandle(db);
  1458         -    }
  1459         -
  1460         -    private SQLiteConnectionHandle()
  1461         -      : base(IntPtr.Zero)
  1462         -    {
         1453  +#if PLATFORM_COMPACTFRAMEWORK
         1454  +        private readonly object syncRoot = new object();
         1455  +#endif
         1456  +
         1457  +        ///////////////////////////////////////////////////////////////////////
         1458  +
         1459  +        public static implicit operator IntPtr(SQLiteConnectionHandle db)
         1460  +        {
         1461  +            if (db != null)
         1462  +            {
         1463  +#if PLATFORM_COMPACTFRAMEWORK
         1464  +                lock (db.syncRoot)
         1465  +#endif
         1466  +                {
         1467  +                    return db.handle;
         1468  +                }
         1469  +            }
         1470  +            return IntPtr.Zero;
         1471  +        }
         1472  +
         1473  +        ///////////////////////////////////////////////////////////////////////
         1474  +
         1475  +        internal SQLiteConnectionHandle(IntPtr db)
         1476  +            : this()
         1477  +        {
         1478  +#if PLATFORM_COMPACTFRAMEWORK
         1479  +            lock (syncRoot)
         1480  +#endif
         1481  +            {
         1482  +                SetHandle(db);
         1483  +            }
         1484  +        }
         1485  +
         1486  +        ///////////////////////////////////////////////////////////////////////
         1487  +
         1488  +        private SQLiteConnectionHandle()
         1489  +            : base(IntPtr.Zero)
         1490  +        {
         1491  +        }
         1492  +
         1493  +        ///////////////////////////////////////////////////////////////////////
         1494  +
         1495  +        protected override bool ReleaseHandle()
         1496  +        {
         1497  +            try
         1498  +            {
         1499  +#if !PLATFORM_COMPACTFRAMEWORK
         1500  +                IntPtr localHandle = Interlocked.Exchange(
         1501  +                    ref handle, IntPtr.Zero);
         1502  +
         1503  +                if (localHandle != IntPtr.Zero)
         1504  +                    SQLiteBase.CloseConnection(this, localHandle);
         1505  +
         1506  +#if !NET_COMPACT_20 && TRACE_HANDLE
         1507  +                try
         1508  +                {
         1509  +                    Trace.WriteLine(String.Format(
         1510  +                        "CloseConnection: {0}", localHandle));
         1511  +                }
         1512  +                catch
         1513  +                {
         1514  +                }
         1515  +#endif
         1516  +#else
         1517  +                lock (syncRoot)
         1518  +                {
         1519  +                    if (handle != IntPtr.Zero)
         1520  +                    {
         1521  +                        SQLiteBase.CloseConnection(this, handle);
         1522  +                        SetHandle(IntPtr.Zero);
         1523  +                    }
         1524  +                }
         1525  +#endif
         1526  +#if DEBUG
         1527  +                return true;
         1528  +#endif
         1529  +            }
         1530  +#if !NET_COMPACT_20 && TRACE_HANDLE
         1531  +            catch (SQLiteException e)
         1532  +#else
         1533  +            catch (SQLiteException)
         1534  +#endif
         1535  +            {
         1536  +#if !NET_COMPACT_20 && TRACE_HANDLE
         1537  +                try
         1538  +                {
         1539  +                    Trace.WriteLine(String.Format(
         1540  +                        "CloseConnection: {0}, exception: {1}",
         1541  +                        handle, e));
         1542  +                }
         1543  +                catch
         1544  +                {
         1545  +                }
         1546  +#endif
         1547  +            }
         1548  +            finally
         1549  +            {
         1550  +#if PLATFORM_COMPACTFRAMEWORK
         1551  +                lock (syncRoot)
         1552  +#endif
         1553  +                {
         1554  +                    SetHandleAsInvalid();
         1555  +                }
         1556  +            }
         1557  +#if DEBUG
         1558  +            return false;
         1559  +#else
         1560  +            return true;
         1561  +#endif
         1562  +        }
         1563  +
         1564  +        ///////////////////////////////////////////////////////////////////////
         1565  +
         1566  +        public override bool IsInvalid
         1567  +        {
         1568  +            get
         1569  +            {
         1570  +#if PLATFORM_COMPACTFRAMEWORK
         1571  +                lock (syncRoot)
         1572  +#endif
         1573  +                {
         1574  +                    return (handle == IntPtr.Zero);
         1575  +                }
         1576  +            }
         1577  +        }
         1578  +
         1579  +        ///////////////////////////////////////////////////////////////////////
         1580  +
         1581  +#if DEBUG
         1582  +        public override string ToString()
         1583  +        {
         1584  +#if PLATFORM_COMPACTFRAMEWORK
         1585  +            lock (syncRoot)
         1586  +#endif
         1587  +            {
         1588  +                return handle.ToString();
         1589  +            }
         1590  +        }
         1591  +#endif
  1463   1592       }
         1593  +    #endregion
  1464   1594   
  1465         -    protected override bool ReleaseHandle()
         1595  +    ///////////////////////////////////////////////////////////////////////////
         1596  +
         1597  +    #region SQLiteStatementHandle Class
         1598  +    // Provides finalization support for unmanaged SQLite statements.
         1599  +    internal class SQLiteStatementHandle : CriticalHandle
  1466   1600       {
  1467         -      try
  1468         -      {
         1601  +#if PLATFORM_COMPACTFRAMEWORK
         1602  +        private readonly object syncRoot = new object();
         1603  +#endif
         1604  +
         1605  +        ///////////////////////////////////////////////////////////////////////
         1606  +
         1607  +        private SQLiteConnectionHandle cnn;
         1608  +
         1609  +        ///////////////////////////////////////////////////////////////////////
         1610  +
         1611  +        public static implicit operator IntPtr(SQLiteStatementHandle stmt)
         1612  +        {
         1613  +            if (stmt != null)
         1614  +            {
         1615  +#if PLATFORM_COMPACTFRAMEWORK
         1616  +                lock (stmt.syncRoot)
         1617  +#endif
         1618  +                {
         1619  +                    return stmt.handle;
         1620  +                }
         1621  +            }
         1622  +            return IntPtr.Zero;
         1623  +        }
         1624  +
         1625  +        ///////////////////////////////////////////////////////////////////////
         1626  +
         1627  +        internal SQLiteStatementHandle(SQLiteConnectionHandle cnn, IntPtr stmt)
         1628  +            : this()
         1629  +        {
         1630  +#if PLATFORM_COMPACTFRAMEWORK
         1631  +            lock (syncRoot)
         1632  +#endif
         1633  +            {
         1634  +                this.cnn = cnn;
         1635  +                SetHandle(stmt);
         1636  +            }
         1637  +        }
         1638  +
         1639  +        ///////////////////////////////////////////////////////////////////////
         1640  +
         1641  +        private SQLiteStatementHandle()
         1642  +            : base(IntPtr.Zero)
         1643  +        {
         1644  +        }
         1645  +
         1646  +        ///////////////////////////////////////////////////////////////////////
         1647  +
         1648  +        protected override bool ReleaseHandle()
         1649  +        {
         1650  +            try
         1651  +            {
  1469   1652   #if !PLATFORM_COMPACTFRAMEWORK
  1470         -        IntPtr localHandle = Interlocked.Exchange(
  1471         -          ref handle, IntPtr.Zero);
         1653  +                IntPtr localHandle = Interlocked.Exchange(
         1654  +                    ref handle, IntPtr.Zero);
  1472   1655   
  1473         -        if (localHandle != IntPtr.Zero)
  1474         -          SQLiteBase.CloseConnection(this, localHandle);
         1656  +                if (localHandle != IntPtr.Zero)
         1657  +                    SQLiteBase.FinalizeStatement(cnn, localHandle);
  1475   1658   
         1659  +#if !NET_COMPACT_20 && TRACE_HANDLE
         1660  +                try
         1661  +                {
         1662  +                    Trace.WriteLine(String.Format(
         1663  +                        "FinalizeStatement: {0}", localHandle));
         1664  +                }
         1665  +                catch
         1666  +                {
         1667  +                }
         1668  +#endif
         1669  +#else
         1670  +                lock (syncRoot)
         1671  +                {
         1672  +                    if (handle != IntPtr.Zero)
         1673  +                    {
         1674  +                        SQLiteBase.FinalizeStatement(cnn, handle);
         1675  +                        SetHandle(IntPtr.Zero);
         1676  +                    }
         1677  +                }
         1678  +#endif
         1679  +#if DEBUG
         1680  +                return true;
         1681  +#endif
         1682  +            }
         1683  +#if !NET_COMPACT_20 && TRACE_HANDLE
         1684  +            catch (SQLiteException e)
         1685  +#else
         1686  +            catch (SQLiteException)
         1687  +#endif
         1688  +            {
  1476   1689   #if !NET_COMPACT_20 && TRACE_HANDLE
  1477         -        try
  1478         -        {
  1479         -          Trace.WriteLine(String.Format(
  1480         -              "CloseConnection: {0}", localHandle));
  1481         -        }
  1482         -        catch
  1483         -        {
  1484         -        }
         1690  +                try
         1691  +                {
         1692  +                    Trace.WriteLine(String.Format(
         1693  +                        "FinalizeStatement: {0}, exception: {1}",
         1694  +                        handle, e));
         1695  +                }
         1696  +                catch
         1697  +                {
         1698  +                }
  1485   1699   #endif
         1700  +            }
         1701  +            finally
         1702  +            {
         1703  +#if PLATFORM_COMPACTFRAMEWORK
         1704  +                lock (syncRoot)
         1705  +#endif
         1706  +                {
         1707  +                    SetHandleAsInvalid();
         1708  +                }
         1709  +            }
         1710  +#if DEBUG
         1711  +            return false;
  1486   1712   #else
  1487         -        if (handle != IntPtr.Zero)
         1713  +            return true;
         1714  +#endif
         1715  +        }
         1716  +
         1717  +        ///////////////////////////////////////////////////////////////////////
         1718  +
         1719  +        public override bool IsInvalid
  1488   1720           {
  1489         -          SQLiteBase.CloseConnection(this, handle);
  1490         -          SetHandle(IntPtr.Zero);
         1721  +            get
         1722  +            {
         1723  +#if PLATFORM_COMPACTFRAMEWORK
         1724  +                lock (syncRoot)
         1725  +#endif
         1726  +                {
         1727  +                    return (handle == IntPtr.Zero);
         1728  +                }
         1729  +            }
  1491   1730           }
  1492         -#endif
         1731  +
         1732  +        ///////////////////////////////////////////////////////////////////////
  1493   1733   
  1494   1734   #if DEBUG
  1495         -        return true;
  1496         -#endif
  1497         -      }
  1498         -#if !NET_COMPACT_20 && TRACE_HANDLE
  1499         -      catch (SQLiteException e)
  1500         -#else
  1501         -      catch (SQLiteException)
  1502         -#endif
  1503         -      {
  1504         -#if !NET_COMPACT_20 && TRACE_HANDLE
  1505         -        try
         1735  +        public override string ToString()
  1506   1736           {
  1507         -          Trace.WriteLine(String.Format(
  1508         -              "CloseConnection: {0}, exception: {1}",
  1509         -              handle, e));
         1737  +#if PLATFORM_COMPACTFRAMEWORK
         1738  +            lock (syncRoot)
         1739  +#endif
         1740  +            {
         1741  +                return handle.ToString();
         1742  +            }
  1510   1743           }
  1511         -        catch
  1512         -        {
  1513         -        }
  1514         -#endif
  1515         -      }
  1516         -      finally
  1517         -      {
  1518         -        SetHandleAsInvalid();
  1519         -      }
  1520         -#if DEBUG
  1521         -      return false;
  1522         -#else
  1523         -      return true;
  1524   1744   #endif
  1525   1745       }
         1746  +    #endregion
  1526   1747   
  1527         -    public override bool IsInvalid
  1528         -    {
  1529         -      get { return (handle == IntPtr.Zero); }
  1530         -    }
         1748  +    ///////////////////////////////////////////////////////////////////////////
  1531   1749   
  1532         -#if DEBUG
  1533         -    public override string ToString()
         1750  +    #region SQLiteBackupHandle Class
         1751  +    // Provides finalization support for unmanaged SQLite backup objects.
         1752  +    internal class SQLiteBackupHandle : CriticalHandle
  1534   1753       {
  1535         -        return handle.ToString();
  1536         -    }
         1754  +#if PLATFORM_COMPACTFRAMEWORK
         1755  +        private readonly object syncRoot = new object();
         1756  +#endif
         1757  +
         1758  +        ///////////////////////////////////////////////////////////////////////
         1759  +
         1760  +        private SQLiteConnectionHandle cnn;
         1761  +
         1762  +        ///////////////////////////////////////////////////////////////////////
         1763  +
         1764  +        public static implicit operator IntPtr(SQLiteBackupHandle backup)
         1765  +        {
         1766  +            if (backup != null)
         1767  +            {
         1768  +#if PLATFORM_COMPACTFRAMEWORK
         1769  +                lock (backup.syncRoot)
         1770  +#endif
         1771  +                {
         1772  +                    return backup.handle;
         1773  +                }
         1774  +            }
         1775  +            return IntPtr.Zero;
         1776  +        }
         1777  +
         1778  +        ///////////////////////////////////////////////////////////////////////
         1779  +
         1780  +        internal SQLiteBackupHandle(SQLiteConnectionHandle cnn, IntPtr backup)
         1781  +            : this()
         1782  +        {
         1783  +#if PLATFORM_COMPACTFRAMEWORK
         1784  +            lock (syncRoot)
  1537   1785   #endif
  1538         -  }
         1786  +            {
         1787  +                this.cnn = cnn;
         1788  +                SetHandle(backup);
         1789  +            }
         1790  +        }
  1539   1791   
  1540         -  // Provides finalization support for unmanaged SQLite statements.
  1541         -  internal class SQLiteStatementHandle : CriticalHandle
  1542         -  {
  1543         -    private SQLiteConnectionHandle cnn;
         1792  +        ///////////////////////////////////////////////////////////////////////
  1544   1793   
  1545         -    public static implicit operator IntPtr(SQLiteStatementHandle stmt)
  1546         -    {
  1547         -      return (stmt != null) ? stmt.handle : IntPtr.Zero;
  1548         -    }
         1794  +        private SQLiteBackupHandle()
         1795  +            : base(IntPtr.Zero)
         1796  +        {
         1797  +        }
  1549   1798   
  1550         -    internal SQLiteStatementHandle(SQLiteConnectionHandle cnn, IntPtr stmt)
  1551         -      : this()
  1552         -    {
  1553         -      this.cnn = cnn;
  1554         -      SetHandle(stmt);
  1555         -    }
         1799  +        ///////////////////////////////////////////////////////////////////////
  1556   1800   
  1557         -    private SQLiteStatementHandle()
  1558         -      : base(IntPtr.Zero)
  1559         -    {
  1560         -    }
  1561         -
  1562         -    protected override bool ReleaseHandle()
  1563         -    {
  1564         -      try
  1565         -      {
         1801  +        protected override bool ReleaseHandle()
         1802  +        {
         1803  +            try
         1804  +            {
  1566   1805   #if !PLATFORM_COMPACTFRAMEWORK
  1567         -        IntPtr localHandle = Interlocked.Exchange(
  1568         -          ref handle, IntPtr.Zero);
         1806  +                IntPtr localHandle = Interlocked.Exchange(
         1807  +                    ref handle, IntPtr.Zero);
  1569   1808   
  1570         -        if (localHandle != IntPtr.Zero)
  1571         -          SQLiteBase.FinalizeStatement(cnn, localHandle);
         1809  +                if (localHandle != IntPtr.Zero)
         1810  +                    SQLiteBase.FinishBackup(cnn, localHandle);
  1572   1811   
         1812  +#if !NET_COMPACT_20 && TRACE_HANDLE
         1813  +                try
         1814  +                {
         1815  +                    Trace.WriteLine(String.Format(
         1816  +                        "FinishBackup: {0}", localHandle));
         1817  +                }
         1818  +                catch
         1819  +                {
         1820  +                }
         1821  +#endif
         1822  +#else
         1823  +                lock (syncRoot)
         1824  +                {
         1825  +                    if (handle != IntPtr.Zero)
         1826  +                    {
         1827  +                        SQLiteBase.FinishBackup(cnn, handle);
         1828  +                        SetHandle(IntPtr.Zero);
         1829  +                    }
         1830  +                }
         1831  +#endif
         1832  +#if DEBUG
         1833  +                return true;
         1834  +#endif
         1835  +            }
         1836  +#if !NET_COMPACT_20 && TRACE_HANDLE
         1837  +            catch (SQLiteException e)
         1838  +#else
         1839  +            catch (SQLiteException)
         1840  +#endif
         1841  +            {
  1573   1842   #if !NET_COMPACT_20 && TRACE_HANDLE
  1574         -        try
  1575         -        {
  1576         -          Trace.WriteLine(String.Format(
  1577         -              "FinalizeStatement: {0}", localHandle));
  1578         -        }
  1579         -        catch
  1580         -        {
  1581         -        }
         1843  +                try
         1844  +                {
         1845  +                    Trace.WriteLine(String.Format(
         1846  +                        "FinishBackup: {0}, exception: {1}",
         1847  +                        handle, e));
         1848  +                }
         1849  +                catch
         1850  +                {
         1851  +                }
         1852  +#endif
         1853  +            }
         1854  +            finally
         1855  +            {
         1856  +#if PLATFORM_COMPACTFRAMEWORK
         1857  +                lock (syncRoot)
  1582   1858   #endif
         1859  +                {
         1860  +                    SetHandleAsInvalid();
         1861  +                }
         1862  +            }
         1863  +#if DEBUG
         1864  +            return false;
  1583   1865   #else
  1584         -        if (handle != IntPtr.Zero)
         1866  +            return true;
         1867  +#endif
         1868  +        }
         1869  +
         1870  +        ///////////////////////////////////////////////////////////////////////
         1871  +
         1872  +        public override bool IsInvalid
  1585   1873           {
  1586         -          SQLiteBase.FinalizeStatement(cnn, handle);
  1587         -          SetHandle(IntPtr.Zero);
  1588         -        }
         1874  +            get
         1875  +            {
         1876  +#if PLATFORM_COMPACTFRAMEWORK
         1877  +                lock (syncRoot)
  1589   1878   #endif
         1879  +                {
         1880  +                    return (handle == IntPtr.Zero);
         1881  +                }
         1882  +            }
         1883  +        }
         1884  +
         1885  +        ///////////////////////////////////////////////////////////////////////
  1590   1886   
  1591   1887   #if DEBUG
  1592         -        return true;
  1593         -#endif
  1594         -      }
  1595         -#if !NET_COMPACT_20 && TRACE_HANDLE
  1596         -      catch (SQLiteException e)
  1597         -#else
  1598         -      catch (SQLiteException)
         1888  +        public override string ToString()
         1889  +        {
         1890  +#if PLATFORM_COMPACTFRAMEWORK
         1891  +            lock (syncRoot)
  1599   1892   #endif
  1600         -      {
  1601         -#if !NET_COMPACT_20 && TRACE_HANDLE
  1602         -        try
  1603         -        {
  1604         -          Trace.WriteLine(String.Format(
  1605         -              "FinalizeStatement: {0}, exception: {1}",
  1606         -              handle, e));
         1893  +            {
         1894  +                return handle.ToString();
         1895  +            }
  1607   1896           }
  1608         -        catch
  1609         -        {
  1610         -        }
  1611         -#endif
  1612         -      }
  1613         -      finally
  1614         -      {
  1615         -        SetHandleAsInvalid();
  1616         -      }
  1617         -#if DEBUG
  1618         -      return false;
  1619         -#else
  1620         -      return true;
  1621   1897   #endif
  1622   1898       }
  1623         -
  1624         -    public override bool IsInvalid
  1625         -    {
  1626         -      get { return (handle == IntPtr.Zero); }
  1627         -    }
  1628         -
  1629         -#if DEBUG
  1630         -    public override string ToString()
  1631         -    {
  1632         -        return handle.ToString();
  1633         -    }
  1634         -#endif
  1635         -  }
  1636         -
  1637         -  // Provides finalization support for unmanaged SQLite backup objects.
  1638         -  internal class SQLiteBackupHandle : CriticalHandle
  1639         -  {
  1640         -      private SQLiteConnectionHandle cnn;
  1641         -
  1642         -      public static implicit operator IntPtr(SQLiteBackupHandle backup)
  1643         -      {
  1644         -          return (backup != null) ? backup.handle : IntPtr.Zero;
  1645         -      }
  1646         -
  1647         -      internal SQLiteBackupHandle(SQLiteConnectionHandle cnn, IntPtr backup)
  1648         -          : this()
  1649         -      {
  1650         -          this.cnn = cnn;
  1651         -          SetHandle(backup);
  1652         -      }
  1653         -
  1654         -      private SQLiteBackupHandle()
  1655         -          : base(IntPtr.Zero)
  1656         -      {
  1657         -      }
  1658         -
  1659         -      protected override bool ReleaseHandle()
  1660         -      {
  1661         -          try
  1662         -          {
  1663         -#if !PLATFORM_COMPACTFRAMEWORK
  1664         -              IntPtr localHandle = Interlocked.Exchange(
  1665         -                  ref handle, IntPtr.Zero);
  1666         -
  1667         -              if (localHandle != IntPtr.Zero)
  1668         -                  SQLiteBase.FinishBackup(cnn, localHandle);
  1669         -
  1670         -#if !NET_COMPACT_20 && TRACE_HANDLE
  1671         -              try
  1672         -              {
  1673         -                  Trace.WriteLine(String.Format(
  1674         -                      "FinishBackup: {0}", localHandle));
  1675         -              }
  1676         -              catch
  1677         -              {
  1678         -              }
  1679         -#endif
  1680         -#else
  1681         -              if (handle != IntPtr.Zero)
  1682         -              {
  1683         -                SQLiteBase.FinishBackup(cnn, handle);
  1684         -                SetHandle(IntPtr.Zero);
  1685         -              }
  1686         -#endif
  1687         -
  1688         -#if DEBUG
  1689         -              return true;
  1690         -#endif
  1691         -          }
  1692         -#if !NET_COMPACT_20 && TRACE_HANDLE
  1693         -          catch (SQLiteException e)
  1694         -#else
  1695         -          catch (SQLiteException)
  1696         -#endif
  1697         -          {
  1698         -#if !NET_COMPACT_20 && TRACE_HANDLE
  1699         -              try
  1700         -              {
  1701         -                  Trace.WriteLine(String.Format(
  1702         -                      "FinishBackup: {0}, exception: {1}",
  1703         -                      handle, e));
  1704         -              }
  1705         -              catch
  1706         -              {
  1707         -              }
  1708         -#endif
  1709         -          }
  1710         -          finally
  1711         -          {
  1712         -              SetHandleAsInvalid();
  1713         -          }
  1714         -#if DEBUG
  1715         -          return false;
  1716         -#else
  1717         -          return true;
  1718         -#endif
  1719         -      }
  1720         -
  1721         -      public override bool IsInvalid
  1722         -      {
  1723         -          get { return (handle == IntPtr.Zero); }
  1724         -      }
  1725         -
  1726         -#if DEBUG
  1727         -      public override string ToString()
  1728         -      {
  1729         -          return handle.ToString();
  1730         -      }
  1731         -#endif
  1732         -  }
         1899  +    #endregion
  1733   1900   }