private static void Finally(AsyncResult result, Exception currentException)
        {
            SqlWorkflowInstanceStoreAsyncResult result2 = result as SqlWorkflowInstanceStoreAsyncResult;

            try
            {
                if (result2.DependentTransaction != null)
                {
                    using (result2.DependentTransaction)
                    {
                        result2.DependentTransaction.Complete();
                    }
                }
            }
            catch (TransactionException)
            {
                if (currentException == null)
                {
                    throw;
                }
            }
            finally
            {
                result2.OnCommandCompletion();
                result2.ClearMembers();
                StoreUtilities.TraceSqlCommand(result2.sqlCommand, false);
            }
        }
        void StartOperation()
        {
            Guid      instanceId       = (this.InstancePersistenceContext != null) ? this.InstancePersistenceContext.InstanceView.InstanceId : Guid.Empty;
            Exception delayedException = null;

            try
            {
                this.sqlCommand = new SqlCommand();
                this.GenerateSqlCommand(this.sqlCommand);
                this.sqlCommand.CommandText = this.GetSqlCommandText();
                this.sqlCommand.CommandType = this.GetSqlCommandType();

                StoreUtilities.TraceSqlCommand(this.sqlCommand, true);
                SqlCommandAsyncResult sqlCommandResult = new SqlCommandAsyncResult(this.sqlCommand, this.ConnectionString,
                                                                                   (this.InstancePersistenceContext != null) ? this.InstancePersistenceContext.EventTraceActivity : null,
                                                                                   this.DependentTransaction, this.TimeoutHelper.RemainingTime(), 0, this.maximumRetries, PrepareAsyncCompletion(onSqlCommandAsyncResultCallback), this);
                sqlCommandResult.StartCommand();

                if (!SyncContinue(sqlCommandResult))
                {
                    return;
                }
            }
            catch (InstancePersistenceException instancePersistenceException)
            {
                delayedException = instancePersistenceException;
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }

                delayedException = new InstancePersistenceCommandException(this.InstancePersistenceCommand.Name, instanceId, exception);
            }

            if (delayedException != null)
            {
                if (this.sqlCommand.Connection != null)
                {
                    this.sqlCommand.Connection.Close();
                }

                this.sqlCommand.Dispose();
                this.TraceException(delayedException);
            }

            this.Complete(false, delayedException);
        }
        private void StartOperation()
        {
            Guid      instanceId = (this.InstancePersistenceContext != null) ? this.InstancePersistenceContext.InstanceView.InstanceId : Guid.Empty;
            Exception exception  = null;

            try
            {
                this.sqlCommand = new SqlCommand();
                this.GenerateSqlCommand(this.sqlCommand);
                this.sqlCommand.CommandText = this.GetSqlCommandText();
                this.sqlCommand.CommandType = this.GetSqlCommandType();
                StoreUtilities.TraceSqlCommand(this.sqlCommand, true);
                SqlCommandAsyncResult result = new SqlCommandAsyncResult(this.sqlCommand, this.ConnectionString, this.DependentTransaction, this.TimeoutHelper.RemainingTime(), 0, this.Store.MaxConnectionRetries, base.PrepareAsyncCompletion(onSqlCommandAsyncResultCallback), this);
                result.StartCommand();
                if (!base.SyncContinue(result))
                {
                    return;
                }
            }
            catch (InstancePersistenceException exception2)
            {
                exception = exception2;
            }
            catch (Exception exception3)
            {
                if (Fx.IsFatal(exception3))
                {
                    throw;
                }
                exception = new InstancePersistenceCommandException(this.InstancePersistenceCommand.Name, instanceId, exception3);
            }
            if (exception != null)
            {
                if (this.sqlCommand.Connection != null)
                {
                    this.sqlCommand.Connection.Close();
                }
                this.sqlCommand.Dispose();
                this.TraceException(exception);
            }
            base.Complete(false, exception);
        }