internal void ValidateAsyncResult(IAsyncResult ar, string endMethod) { if (ar == null) { throw new ArgumentException("result passed is null!"); } if (!(ar is SqlAsyncResult)) { throw new ArgumentException(String.Format("cannot test validity of types {0}", ar.GetType())); } SqlAsyncResult result = (SqlAsyncResult)ar; if (result.EndMethod != endMethod) { throw new InvalidOperationException(String.Format("Mismatched {0} called for AsyncResult. " + "Expected call to {1} but {0} is called instead.", endMethod, result.EndMethod)); } if (result.Ended) { throw new InvalidOperationException(String.Format("The method {0} cannot be called " + "more than once for the same AsyncResult.", endMethod)); } }
internal void EndExecuteInternal(IAsyncResult ar) { SqlAsyncResult sqlResult = ((SqlAsyncResult)ar); Connection.Tds.WaitFor(sqlResult.InternalResult); Connection.Tds.CheckAndThrowException(sqlResult.InternalResult); }
public IAsyncResult BeginExecuteNonQuery(AsyncCallback callback, object stateObject) { ValidateCommand("BeginExecuteNonQuery", true); SqlAsyncResult ar = new SqlAsyncResult(callback, stateObject); ar.EndMethod = "EndExecuteNonQuery"; ar.InternalResult = BeginExecuteInternal(CommandBehavior.Default, false, ar.BubbleCallback, ar); return(ar); }
public IAsyncResult BeginExecuteXmlReader(AsyncCallback callback, object stateObject) { ValidateCommand("BeginExecuteXmlReader", true); SqlAsyncResult ar = new SqlAsyncResult(callback, stateObject); ar.EndMethod = "EndExecuteXmlReader"; ar.InternalResult = BeginExecuteInternal(behavior, true, ar.BubbleCallback, stateObject); return(ar); }
public IAsyncResult BeginExecuteReader(AsyncCallback callback, object state, CommandBehavior behavior) { ValidateCommand("BeginExecuteReader"); this.behavior = behavior; SqlAsyncResult ar = new SqlAsyncResult(callback, state); ar.EndMethod = "EndExecuteReader"; IAsyncResult tdsResult = BeginExecuteInternal(behavior, true, ar.BubbleCallback, state); ar.InternalResult = tdsResult; return(ar); }
public IAsyncResult BeginExecuteXmlReader (AsyncCallback callback, object stateObject) { ValidateCommand ("BeginExecuteXmlReader", true); SqlAsyncResult ar = new SqlAsyncResult (callback, stateObject); ar.EndMethod = "EndExecuteXmlReader"; ar.InternalResult = BeginExecuteInternal (behavior, true, ar.BubbleCallback, stateObject); return ar; }
public IAsyncResult BeginExecuteReader (AsyncCallback callback, object stateObject, CommandBehavior behavior) { ValidateCommand ("BeginExecuteReader", true); this.behavior = behavior; SqlAsyncResult ar = new SqlAsyncResult (callback, stateObject); ar.EndMethod = "EndExecuteReader"; IAsyncResult tdsResult = BeginExecuteInternal (behavior, true, ar.BubbleCallback, stateObject); ar.InternalResult = tdsResult; return ar; }
public IAsyncResult BeginExecuteNonQuery (AsyncCallback callback, object stateObject) { ValidateCommand ("BeginExecuteNonQuery", true); SqlAsyncResult ar = new SqlAsyncResult (callback, stateObject); ar.EndMethod = "EndExecuteNonQuery"; ar.InternalResult = BeginExecuteInternal (CommandBehavior.Default, false, ar.BubbleCallback, ar); return ar; }