dotConnect for DB2 Documentation
Devart.Common Namespace / DbDataTable Class / NonBlocking Property
Example

In This Topic
    NonBlocking Property
    In This Topic
    Gets or sets data request mode.
    Syntax
    'Declaration
     
    Public Property NonBlocking As Boolean
    public bool NonBlocking {get; set;}

    Property Value

    If this property is true, true, and the FetchAll property is true also, the data is requested asynchronously.
    Remarks
    When FetchAll property is false, the NonBlocking property is ignored. When both FetchAll and NonBlocking properties are true, the fill operation is performed asynchronously, and you can use SuspendFill, EndFill, and other asynchronous methods.
    Example
    The following example demonstrates how to use the NonBlocking property.
    static void UseDataTable(DbDataTable myDataTable, DbConnection myConnection) {
    
      myDataTable.Connection = myConnection;
      myDataTable.SelectCommand = myConnection.CreateCommand();
      myDataTable.SelectCommand.CommandText = "SELECT * FROM Dept";
      myDataTable.NonBlocking = true;
      myDataTable.Active = true;
      
      while ( true ) {
        Thread.Sleep(100);
        bool isFetching = !System.Threading.Monitor.TryEnter(myDataTable.SyncRoot, 0);
        if (!isFetching)
          System.Threading.Monitor.Exit(myDataTable.SyncRoot);
        else
          break;
        Console.Write("Fetch in process");
      }
      Console.Write("All records are fetched");
    }
    Private Shared Sub UseDataTable(ByVal myDataTable As DbDataTable, ByVal myConnection As DbConnection)
      myDataTable.Connection = myConnection
      myDataTable.SelectCommand = myConnection.CreateCommand
      myDataTable.SelectCommand.CommandText = "SELECT * FROM Dept"
      myDataTable.NonBlocking = True
      myDataTable.Active = True
      Do While True
        Thread.Sleep(100)
        If Not Monitor.TryEnter(myDataTable.SyncRoot, 0) Then
          Console.Write("All records are fetched")
          Return
        End If
        Monitor.Exit(myDataTable.SyncRoot)
        Console.Write("Fetch in process")
      Loop
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also