Which code segment should you use?

You have an SQL query that takes one minute to execute. You use the following code segment to execute the SQL query asynchronously.

Dim ar As IAsyncResult = cmd.BeginExecuteReader()

You need to execute a method named DoWork() that takes one second to run while the SQL query is executing. DoWork() must run as many times as possible while the SQL query is executing. Which code segment should you use?

You have an SQL query that takes one minute to execute. You use the following code segment to execute the SQL query asynchronously.

Dim ar As IAsyncResult = cmd.BeginExecuteReader()

You need to execute a method named DoWork() that takes one second to run while the SQL query is executing. DoWork() must run as many times as possible while the SQL query is executing. Which code segment should you use?

A.
While ar.AsyncWaitHandle Is Nothing DoWork()End Whiledr = cmd.EndExecuteReader(ar)

B.
While Not ar.IsCompleted DoWork()End Whiledr = cmd.EndExecuteReader(ar)

C.
While Thread.CurrentThread.ThreadState = ThreadState.Running DoWork()End Whiledr = cmd.EndExecuteReader(ar)

D.
While Not ar.AsyncWaitHandle.WaitOne() DoWork()End Whiledr = cmd.EndExecuteReader(ar)



Leave a Reply 0

Your email address will not be published. Required fields are marked *