static bool OnRetryCommand(IAsyncResult childPtr) { SqlCommandAsyncResult parentPtr = (SqlCommandAsyncResult)(childPtr.AsyncState); parentPtr.sqlDataReader = SqlCommandAsyncResult.End(childPtr); return(true); }
private static bool SqlCommandAsyncResultCallback(IAsyncResult result) { SqlWorkflowInstanceStoreAsyncResult asyncState = (SqlWorkflowInstanceStoreAsyncResult)result.AsyncState; Exception exception = null; bool flag = true; try { using (asyncState.sqlCommand) { using (SqlDataReader reader = SqlCommandAsyncResult.End(result)) { exception = asyncState.ProcessSqlResult(reader); } } } catch (Exception exception2) { if (Fx.IsFatal(exception2)) { throw; } Guid instanceId = (asyncState.InstancePersistenceContext != null) ? asyncState.InstancePersistenceContext.InstanceView.InstanceId : Guid.Empty; exception = new InstancePersistenceCommandException(asyncState.InstancePersistenceCommand.Name, instanceId, exception2); } if (exception is InstanceAlreadyLockedToOwnerException) { InstanceAlreadyLockedToOwnerException exception3 = (InstanceAlreadyLockedToOwnerException)exception; long instanceVersion = exception3.InstanceVersion; if (!asyncState.InstancePersistenceContext.InstanceView.IsBoundToInstance) { asyncState.InstancePersistenceContext.BindInstance(exception3.InstanceId); } IAsyncResult result3 = asyncState.InstancePersistenceContext.BeginBindReclaimedLock(instanceVersion, asyncState.TimeoutHelper.RemainingTime(), asyncState.PrepareAsyncCompletion(onBindReclaimed), asyncState); if (!asyncState.SyncContinue(result3)) { flag = false; } return(flag); } if (exception == null) { return(flag); } if (asyncState.sqlCommand.Connection != null) { asyncState.sqlCommand.Connection.Close(); } asyncState.TraceException(exception); throw FxTrace.Exception.AsError(exception); }
static bool SqlCommandAsyncResultCallback(IAsyncResult result) { SqlWorkflowInstanceStoreAsyncResult thisPtr = (SqlWorkflowInstanceStoreAsyncResult)result.AsyncState; Exception delayedException = null; bool completeFlag = true; try { using (thisPtr.sqlCommand) { using (SqlDataReader reader = SqlCommandAsyncResult.End(result)) { delayedException = thisPtr.ProcessSqlResult(reader); } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } Guid instanceId = (thisPtr.InstancePersistenceContext != null) ? thisPtr.InstancePersistenceContext.InstanceView.InstanceId : Guid.Empty; delayedException = new InstancePersistenceCommandException(thisPtr.InstancePersistenceCommand.Name, instanceId, exception); } if (delayedException is InstanceAlreadyLockedToOwnerException) { InstanceAlreadyLockedToOwnerException alreadyLockedException = (InstanceAlreadyLockedToOwnerException)delayedException; long reclaimLockAtVersion = alreadyLockedException.InstanceVersion; if (!thisPtr.InstancePersistenceContext.InstanceView.IsBoundToInstance) { thisPtr.InstancePersistenceContext.BindInstance(alreadyLockedException.InstanceId); } IAsyncResult bindReclaimedAsyncResult = thisPtr.InstancePersistenceContext.BeginBindReclaimedLock(reclaimLockAtVersion, thisPtr.TimeoutHelper.RemainingTime(), thisPtr.PrepareAsyncCompletion(SqlWorkflowInstanceStoreAsyncResult.onBindReclaimed), thisPtr); if (!thisPtr.SyncContinue(bindReclaimedAsyncResult)) { completeFlag = false; } } else if (delayedException != null) { if (thisPtr.sqlCommand.Connection != null) { thisPtr.sqlCommand.Connection.Close(); } bool handled = false; thisPtr.OnSqlException(delayedException, out handled); if (!handled) { thisPtr.TraceException(delayedException); throw FxTrace.Exception.AsError(delayedException); } } if (completeFlag) { completeFlag = thisPtr.OnSqlProcessingComplete(); } return(completeFlag); }