コード例 #1
0
 private async Task InterceptAsync(Task task, ISessionScope scope, CancellationToken ct)
 {
     await task.ContinueWith(async t =>
     {
         await scope.SaveChangesAsync(ct);
         scope.Dispose();
     }, ct).ConfigureAwait(false);
 }
コード例 #2
0
 ///<summary>
 ///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 ///</summary>
 ///<filterpriority>2</filterpriority>
 public void Dispose()
 {
     usageCount -= 1;
     if (usageCount != 0)
     {
         return;
     }
     UnitOfWork.DisposeUnitOfWork(this);
     scope.Dispose();
 }
コード例 #3
0
        private async Task <T> InterceptAsync <T>(Task <T> task, ISessionScope scope, CancellationToken ct)
        {
            var result = await task.ContinueWith(async t =>
            {
                var res = t.Result;
                await scope.SaveChangesAsync(ct);
                scope.Dispose();

                return(res);
            }, ct).ConfigureAwait(false);

            return(await result);
        }