tagged [task-parallel-library]
Update UI Label when using Task.Factory.StartNew
Update UI Label when using Task.Factory.StartNew I am trying to make my UI more responsive in my WPF app. I spawn a new thread using In that method `RecurseAndDeleteStart()` I want to update a label i...
- Modified
- 20 May at 18:9
Is it safe to put TryDequeue in a while loop?
Is it safe to put TryDequeue in a while loop? I have not used concurrent queue before. Is it OK to use TryDequeue as below, in a while loop? Could this not get stuck forever?
- Modified
- 23 May at 14:20
Best way to handle null task inside async method?
Best way to handle null task inside async method? What is the best way to handle a `null` task inside an `async` method? ``` public class MyClass { private readonly Task task; public MyClass(Task ta...
- Modified
- 18 Dec at 16:27
Task.Delay for more than int.MaxValue milliseconds
Task.Delay for more than int.MaxValue milliseconds The maximum duration a `Task.Delay` can be told to delay is `int.MaxValue` milliseconds. What is the cleanest way to create a `Task` which will delay...
- Modified
- 3 May at 21:27
Parallel.ForEach vs Task.Factory.StartNew
Parallel.ForEach vs Task.Factory.StartNew What is the difference between the below code snippets? Won't both be using threadpool threads? For instance if I want to call a function for each item in a c...
- Modified
- 15 Feb at 20:33
What's the difference between Task.Start/Wait and Async/Await?
What's the difference between Task.Start/Wait and Async/Await? I may be missing something but what is the difference between doing: ``` public void MyMethod() { Task t = Task.Factory.StartNew(DoSomet...
- Modified
- 24 Jun at 16:9
How to transform task.Wait(CancellationToken) to an await statement?
How to transform task.Wait(CancellationToken) to an await statement? So, `task.Wait()` can be transformed to `await task`. The semantics are different, of course, but this is roughly how I would go ab...
- Modified
- 26 Oct at 04:13
How to consume HttpClient from F#?
How to consume HttpClient from F#? I'm new to F# and stuck in understanding async in F# from the perspective of a C# developer. Say having the following snippet in C#: How to write the same in F#?
- Modified
- 4 Oct at 17:11
What is the C# equivalent to Promise.all?
What is the C# equivalent to Promise.all? I would like to fetch data from multiple locations from Firebase Realtime Database like described [here](https://stackoverflow.com/a/43485344/4841380) and [he...
- Modified
- 4 Aug at 23:59
How to get the current task reference?
How to get the current task reference? How can I get reference to the task my code is executed within? ``` ISomeInterface impl = new SomeImplementation(); Task.Factory.StartNew(() => impl.MethodFromSo...
- Modified
- 24 Mar at 23:30
Await for list of Tasks
Await for list of Tasks I'm trying to do something like this: Now I would like to wait for all these tasks to complete. Besides doing Is there anything I could d
- Modified
- 3 Jan at 00:55
Execute task in background in WPF application
Execute task in background in WPF application Example What is the recommended approach (TAP or TPL or BackgroundWorker or Dispatcher or others) if I want `Start()` to 1. not block the UI t
- Modified
- 20 Nov at 23:18
Task.Faulted and Task.Exception
Task.Faulted and Task.Exception Neither [TaskStatus Enum](https://msdn.microsoft.com/en-us/library/system.threading.tasks.taskstatus%28v=vs.110%29.aspx) or [Task.Exception](https://msdn.microsoft.com/...
- Modified
- 28 Aug at 14:22
No ConcurrentList<T> in .Net 4.0?
No ConcurrentList in .Net 4.0? I was thrilled to see the new `System.Collections.Concurrent` namespace in .Net 4.0, quite nice! I've seen `ConcurrentDictionary`, `ConcurrentQueue`, `ConcurrentStack`, ...
- Modified
- 30 Aug at 13:44
Construct Task from WaitHandle.Wait
Construct Task from WaitHandle.Wait I chose to return `Task` and `Task` from my objects methods to provide easy consumation by the gui. Some of the methods simply wait for mutex of other kind of waith...
- Modified
- 6 Dec at 10:31
What is the correct way to cancel an async operation that doesn't accept a CancellationToken?
What is the correct way to cancel an async operation that doesn't accept a CancellationToken? What is the correct way to cancel the following? Simply calling `tcpListener.Stop()` seems to result in an...
- Modified
- 15 Nov at 15:19
what happens if I await a task that is already running or ran?
what happens if I await a task that is already running or ran? There is a Task variable and lets say the task is running right now.. by executing the following line. I was wondering what happens when ...
- Modified
- 7 Sep at 08:43
ThreadPool.QueueUserWorkItem vs Task.Factory.StartNew
ThreadPool.QueueUserWorkItem vs Task.Factory.StartNew What is difference between the below vs If the above code is called 500 times for some long running task, does it mean all the thread pool threads...
- Modified
- 2 Jul at 10:53
How to get thread Id in C#
How to get thread Id in C# ``` public bool HasItemsFromPropertySet(InfoItemPropertySet propertySet, CompositeInfoItem itemRemoved) { var itemAndSubItems = new InfoItemCollection(); if (itemR...
- Modified
- 19 Apr at 09:19
Should methods returning Task<T> always start the returned task?
Should methods returning Task always start the returned task? If I have a method like Would it be a better practice to return a started task or just `return new Task(() => ...)` Personally, I prefer t...
- Modified
- 29 Jul at 04:54
Difference between DataflowBlockOptions.BoundedCapacity and BufferBlock<T>
Difference between DataflowBlockOptions.BoundedCapacity and BufferBlock Let's assume i have a simple `ActionBlock` I can specify a bounded capacity to enable buffering: ``` var actionBlock = new Actio...
- Modified
- 9 Feb at 21:49
List<T> thread safety
List thread safety I am using the below code Is the above code thread safe? Is there a chance of processed list getting corrupted? Or should i use a lock before adding? ``` var processed = new List();...
- Modified
- 16 Feb at 18:22
How to empty a BlockingCollection
How to empty a BlockingCollection I have a thread adding items to a `BlockingCollection` . On another thread I am using `foreach (var item in myCollection.GetConsumingEnumerable())` If there is a prob...
- Modified
- 3 Nov at 20:11
.NET 4 equivalent of Task.WhenAll()
.NET 4 equivalent of Task.WhenAll() In .NET 4, is there any functional equivalent to .NET 4.5's [System.Threading.Tasks.Task.WhenAll()](http://msdn.microsoft.com/en-us/library/hh160384%28v=vs.110%29.a...
- Modified
- 16 Jul at 21:7
Combine the result of two parallel tasks in one list
Combine the result of two parallel tasks in one list I want to combine the result of 2 tasks in one List collection. ## Code: Method1: Method2: Now, I want to hold the re
- Modified
- 2 Dec at 00:8