// トランザクションの開始 (UsingTran オブジェクト作成) public async Task <UsingTran> UsingTranAsync(IsolationLevel?isolationLevel = null) { UsingTran t = new UsingTran(this); await BeginAsync(isolationLevel); return(t); }
// トランザクションの開始 (UsingTran オブジェクト作成) public UsingTran UsingTran(IsolationLevel?isolationLevel = null) { UsingTran t = new UsingTran(this); Begin(isolationLevel); return(t); }
public async Task TranAsync(IsolationLevel?isolationLevel, DeadlockRetryConfig?retryConfig, TransactionalTaskAsync task) { await EnsureOpenAsync(); if (retryConfig == null) { retryConfig = this.DeadlockRetryConfig; } int numRetry = 0; LABEL_RETRY: try { using (UsingTran u = this.UsingTran(isolationLevel)) { if (await task()) { u.Commit(); } } } catch (SqlException sqlex) { //sqlex._Debug(); if (sqlex.Number == 1205) { // デッドロック発生 numRetry++; if (numRetry <= retryConfig.RetryCount) { await Task.Delay(Util.RandSInt31() % retryConfig.RetryAverageInterval); goto LABEL_RETRY; } throw; } else { throw; } } }
public void Tran(IsolationLevel?isolationLevel, DeadlockRetryConfig?retryConfig, TransactionalTask task) { EnsureOpen(); if (retryConfig == null) { retryConfig = this.DeadlockRetryConfig; } int numRetry = 0; LABEL_RETRY: try { using (UsingTran u = this.UsingTran(isolationLevel)) { if (task()) { u.Commit(); } } } catch (SqlException sqlex) { if (sqlex.Number == 1205) { // デッドロック発生 numRetry++; if (numRetry <= retryConfig.RetryCount) { Kernel.SleepThread(Util.RandSInt31() % retryConfig.RetryAverageInterval); goto LABEL_RETRY; } throw; } else { throw; } } }