I want to know when "continueWhith" has exceptions.
I made a code like this.
Task.Factory.StartNew(() =>
{
   if(HasException())
       throw new Exception("Exception");
   // Logic
}).ContinueWith(x =>
{
   // Do something to UI.
}, CancellationToken.None, TaskContinuationOptions.NotOnFaulted, 
_uiScheduler).continueWith(x =>
{
   if (x.Exception.IsNotNull()) // Exception handling here.
     ShowExceptionMessage(x.Exception);            
}
I expected to there was an exception in the task at last continueWith, but it wasn't.
Is it right that there isn't an Exception in the Task at last continueWith?
and I want to know how to set an exception property in continueWith.
Thank you.
                        
Yes, because it's a continuation from your "Do something to UI" task. There would only be an exception in
x.Exceptionif that second task had failed.In fact, I wouldn't expect you to reach either continuation, as your first task is always faulted and the first continuation explicitly says to only execute if it's not faulted.
Alternatives:
TaskContinuationOptions.OnlyOnFaultedfor the second continuation - then you don't need the exception check at all.)Ideally, I'd suggest using async/await instead of all of the continuation passing though. It tends to make things a lot simpler.