C# - Error propagation with ContinueWith
问题 I'm a threading newbie and am trying to use SemaphoreSlim to allow me to run a set number of long tasks simultaneously. My challenge is that, given the way I've written it, any exceptions are not being captured correctly. Here's a very simplified example of my current code: public void ThreadTest() { try { var currentTasks = new List<Task>(); SemaphoreSlim maxThread = new SemaphoreSlim(2); for (int i = 1; i < 5; ++i) { maxThread.Wait(); var testTask = Faulty().ContinueWith(tsk => maxThread