Example #1
0
        protected override void State_Changed(SynchronizedStateEventArgs <SupercedableTaskState <TSource, TResult> > args)
        {
            using (SynchronizedStateChange <int> idChange = _currentTaskId.ChangeState())
                idChange.NewState = args.CurrentState.TaskId;

            args.CurrentState.ContinueWith(StateChangeContinuation);
        }
Example #2
0
 public Task ChangeStateAsync(object userState, Action <SynchronizedStateChange <TState> > action)
 {
     return(Task.Factory.StartNew(o =>
     {
         object[] args = o as object[];
         Action <SynchronizedStateChange <TState> > a = args[0] as Action <SynchronizedStateChange <TState> >;
         using (SynchronizedStateChange <TState> changeState = ChangeState(args[1]))
             a(changeState);
     }, new object[] { action, userState }));
 }
Example #3
0
 private void StateChangeContinuation(Task <TResult> task)
 {
     using (SynchronizedStateChange <int> idChange = _currentTaskId.ChangeState())
     {
         if (task.Id == _currentTaskId.CurrentState)
         {
             try { CurrentResult = task.Result; }
             catch (Exception exception) { CurrentError = exception; }
         }
     }
 }
Example #4
0
        public void StartNew(TSource source, Func <TSource, CancellationToken, TResult> function)
        {
            if (function == null)
            {
                throw new ArgumentNullException("function");
            }

            using (SynchronizedStateChange <SupercedableTaskState <TSource, TResult> > stateChange = ChangeState())
                stateChange.NewState = SupercedableTaskState <TSource, TResult> .CheckSupercede(stateChange.CurrentState, source, function);
        }
Example #5
0
 public void StartNew(TSource source, TResult value)
 {
     using (SynchronizedStateChange <SupercedableTaskState <TSource, TResult> > stateChange = ChangeState())
         stateChange.NewState = SupercedableTaskState <TSource, TResult> .CheckSupercede(stateChange.CurrentState, source, value);
 }