Hi everyone,
I'm having a problem with the new asynchrounous ADO.NET operations
(specifically BeginExecuteReader & EndExecuteReader), and was wondering
if anyone else has had similar issues?
I'm getting the following exception:
System.InvalidOperationException: The asynchronous operation has
already completed.
at
System.Data.SqlClient.SqlCommand.VerifyEndExecuteS tate(DbAsyncResult
dbAsyncResult, String endMethod)
at
System.Data.SqlClient.SqlCommand.InternalEndExecut eReader(IAsyncResult
asyncResult, String endMethod)
at System.Data.SqlClient.SqlCommand.EndExecuteReader( IAsyncResult
asyncResult)
Inside the second of the following two methods:
public override void GetAsyncResponse(SessionState state)
{
this.state = state;
state.Response = new SSETIResponse("INB1");
con.Open();
asyncCom = new SqlCommand("sy_inetnewbasket", con);
asyncCom.CommandType = CommandType.StoredProcedure;
Database.BeginExecuteReader(asyncCom, new
AsyncCallback(FinishedWaiting), state);
}
protected void FinishedWaiting(IAsyncResult res)
{
try
{
object o = null;
using(SqlDataReader rdr = asyncCom.EndExecuteReader(res))
{
if(rdr.Read()) o = rdr[0];
}
state.Response.Body = (o == null || o == Convert.DBNull) ? "F" :
int.Parse(o.ToString()).ToString("00000000");
state.SendMessageCallback(state);
}
catch(Exception e)
{
SSETIException.HandleMessageException(e, state);
}
}
I don't see how the .EndExecuteReader could ever get called twice with
the same IAsyncResult - and it only happens under high load (its a
server app) so I'm beginning to think its some weird threading issue
inside the framework?
Any help anyone could add would be great - even if it is just a "its a
bug!" message!
Cheers,
Kieran