You have an SQL query that takes one minute to execute. You use the following code segment to execute the SQL query asynchronously.IAsyncResult ar = cmd.BeginExecuteReader();You need to execute a method named Do Work() 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? ()
- Awhile(ar.AsyncWaitHandle==null){DoWork();}dr=cmd.EndExecuteReader(ar);
- Bwhile(!ar.IsCompleted){DoWork();}dr=cmd.EndExecuteReader(ar);
- Cwhile(Thread.CurrentThread.ThreadState==ThreadState.Running){DoWork();}dr=cmd.EndExecuteReader(ar);
- Dwhile(!ar.AsyncWaitHandle.WaitOne()){DoWork();}dr=cmd.EndExecuteReader(ar);