static void UseDataTable(DbDataTable myDataTable, DbConnection myConnection) {
myDataTable.Connection = myConnection;
myDataTable.SelectCommand = myConnection.CreateCommand();
myDataTable.SelectCommand.CommandText = "SELECT * FROM Test.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");
}