dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OracleCommand Class / EndExecuteReader Method
The System.IAsyncResult returned from BeginExecuteReader.
Example

In This Topic
    EndExecuteReader Method (OracleCommand)
    In This Topic
    Ends an asynchronous invocation of the ExecuteReader method.
    Ends an asynchronous invocation of the ExecuteReader method.
    Syntax
    'Declaration
     
    Public Shadows Function EndExecuteReader( _
       ByVal result As IAsyncResult _
    ) As OracleDataReader
    public new OracleDataReader EndExecuteReader( 
       IAsyncResult result
    )

    Parameters

    result
    The System.IAsyncResult returned from BeginExecuteReader.

    Return Value

    Remarks
    The function ends an asynchronous execution of a query that is started with BeginExecuteReader. A pair of asynchronous functions (BeginExecuteReader and EndExecuteReader) can be used instead of the synchronous function ExecuteReader to gain more performance and flexibility in your application.

    Refer to "Asynchronous Query Execution" article for detailed information.

    Example
    In the example below an easiest way of executing an asynchronous operation is shown. First, all components are set up and a connection is opened. Second, a data retrieval operation is started. The operation state (done or in progress) is checked and a report is written to the console. At last query results are sent to OracleDataReader and rendered to the console.
    Public void Async_Exec(OracleConnection myConnection)
    {
      OracleCommand myCommand = new OracleCommand("SELECT * FROM Test.Dept",myConnection);
      Console.WriteLine("Starting asynchronous retrieval of data...");
      myConnection.Open();
      IAsyncResult cres = myCommand.BeginExecuteReader(null,null,CommandBehavior.Default);
      if (cres.IsCompleted)
        Console.WriteLine("Completed.");
      else
        Console.WriteLine("Have to wait for operation to complete...");
      OracleDataReader myReader = myCommand.EndExecuteReader(cres);
      try
      {
        while (myReader.Read())
        {
          Console.WriteLine(myReader.GetInt32(0) + " " + myReader.GetString(1) + " " + myReader.GetString(2));
        }
      }
      finally
      {
        myReader.Close();
        myConnection.Close();
      }
    }
    Public Sub Async_Exec(ByVal myConnection As OracleConnection)
      Dim myCommand As New OracleCommand("SELECT * FROM Test.Dept", myConnection)
      Console.WriteLine("Starting asynchronous retrieval of data...")
      myConnection.Open()
      Dim cres As IAsyncResult = myCommand.BeginExecuteReader(Nothing, Nothing, CommandBehavior.Default)
      If cres.IsCompleted Then
        Console.WriteLine("Completed.")
      Else
        Console.WriteLine("Have to wait for operation to complete...")
      End If
      Dim myReader As OracleDataReader = myCommand.EndExecuteReader(cres)
      Try
        While myReader.Read()
          Console.WriteLine(String.Concat(myReader.GetInt32(0), " ", myReader.GetString(1), " ", myReader.GetString(2)))
        End While
      Finally
        myReader.Close()
        myConnection.Close()
      End Try
    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