Another common mistake is to ‘forget’ to pass AsyncCallback delegate to the begin method. It is relatively easy to 'forget' because there are overloads of some 'begin' methods that don’t take AsyncCallback parameter. In the following example a wrong overload of SqlCommend.BeginExecuteReader is used:
IAsyncResult BeginGetAsyncData(Object src, EventArgs args, AsyncCallback cb, Object state) { _myCommand = new SqlCommand(…); return _myCommand.BeginExecuteReader(); }
IAsyncResult BeginGetAsyncData(Object src, EventArgs args, AsyncCallback cb, Object state) { _myCommand = new SqlCommand(…); return _myCommand.BeginExecuteReader(cb, state); }