예제 #1
0
        protected sealed override async Task start()
        {
            if (_current == null)
            {
                _lockObject = LockObject.GetValue();

                await _lockObject.WaitAsync().ConfigureAwait(false);

                _current = Activity;
            }

            try
            {
                var task = _current.Start();

                Status = _current.Status;

                await task;

                Status = _current.Status;

                if (_current.Status.IsSuspended())
                {
                    return;
                }
            }
            catch
            {
                if (_lockObject != null)
                {
                    _lockObject.Release();
                    _lockObject = null;
                }

                throw;
            }

            if (_lockObject != null)
            {
                _lockObject.Release();
                _lockObject = null;
            }
        }