I Have the following code, the exception thrown by methodThatThrowsException get silent, how can I throw the exception ?
TaskScheduler scheduler = TaskScheduler.FromCurrentSynchronizationContext();
CancellationToken token = new CancellationToken();
Task task = Task.Factory.StartNew(MethodThatThrowsException)
.ContinueWith(t => { throw t.Exception; }, token, TaskContinuationOptions.OnlyOnFaulted, scheduler)
.ContinueWith(w => Vm.StatusMessage.StopProgressBar(), token, TaskContinuationOptions.OnlyOnRanToCompletion, scheduler);