When to dispose CancellationTokenSource?
The class CancellationTokenSource is disposable. A quick look in Reflector proves usage of KernelEvent, a (very likely) unmanaged resource. Since CancellationTokenSource has no … Read more
The class CancellationTokenSource is disposable. A quick look in Reflector proves usage of KernelEvent, a (very likely) unmanaged resource. Since CancellationTokenSource has no … Read more
I was thrilled to see the new System.Collections.Concurrent namespace in .Net 4.0, quite nice! I’ve seen ConcurrentDictionary, ConcurrentQueue, ConcurrentStack, ConcurrentBag and BlockingCollection. One … Read more
I may be missing something but what is the difference between doing: public void MyMethod() { Task t = Task.Factory.StartNew(DoSomethingThatTakesTime); t.Wait(); UpdateLabelToSayItsComplete(); } … Read more
I want to create a completed Task (not Task<T>). Is there something built into .NET to do this? A related question: Create a … Read more
This question already has answers here: Parallel foreach with asynchronous lambda (11 answers) Closed 3 months ago. In a metro app, I need … Read more
Certain System.Threading.Tasks.Task constructors take a CancellationToken as a parameter: CancellationTokenSource source = new CancellationTokenSource(); Task t = new Task (/* method */, source.Token); … Read more
It works fine when have one or two tasks however throws an error “A task was cancelled” when we have more than one … Read more
In C# and TPL (Task Parallel Library), the Task class represents an ongoing work that produces a value of type T. I’d like … Read more
I would like to handle a collection in parallel, but I’m having trouble implementing it and I’m therefore hoping for some help. The … Read more
AFAIK, all it knows is that at some point, its SetResult or SetException method is being called to complete the Task<T> exposed through … Read more