public WorkUnit Begin()
 {
     _transaction = _session.BeginTransaction();
     var work = new WorkUnit();
     work.Ended += HandleEnded;
     _workUnits.Add(work);
     return work;
 }
 private void HandleEnded(WorkUnit sender, WorkEventArgs e)
 {
     sender.Ended -= HandleEnded;
     if (_workUnits.Any(w => !w.Equals(sender) && !w.HasEnded))
     {
         return;
     }
     EndTransaction(_workUnits.All(w => w.IsComplete));
 }
 private void HandleEnded(WorkUnit sender, WorkEventArgs e)
 {
     sender.Ended -= HandleEnded;
     if (_workUnits.Any(w => !w.Equals(sender) && !w.HasEnded))
     {
         return;
     }
     EndTransaction(_workUnits.All(w => w.IsComplete));
 }
        public WorkUnit Begin()
        {
            _transaction = _session.BeginTransaction();
            var work = new WorkUnit();

            work.Ended += HandleEnded;
            _workUnits.Add(work);
            return(work);
        }