Skip to main content
0 votes
1 answer
123 views

I have the following C# code : var rand = new Random(1); var range = Enumerable.Range(1, 8); var partition = Partitioner.Create(range, EnumerablePartitionerOptions.NoBuffering); foreach (var x in ...
tigrou's user avatar
  • 4,596
1 vote
2 answers
175 views

I have some code in a dll project with the target as .Net 8. In my code there is an async method called EmailNonError which is being called with the following code. When this code executes, the email ...
Sunil's user avatar
  • 21.6k
0 votes
1 answer
59 views

The first exception does not block the execution: public static async Task Main() { await Task.WhenAny( Task.WhenAll( Task.Run(() => throw new Exception(&...
user26757851's user avatar
0 votes
0 answers
108 views

Here's my example code. It's of no use, but it's short. I have an array to switch on or off the creation of Exceptions at different parts of my code and two functions. The first (Level 0) is an ...
Nostromo's user avatar
  • 1,294
0 votes
2 answers
96 views

For the following code snippets, I'm wondering what the actual differences are, when they are executed. The first snippet using await: public async Task LoadAsync() { task = loader.LoadAsync(...); ...
uebe's user avatar
  • 548
1 vote
1 answer
135 views

I'm trying to understand how exception handling works with TaskCompletionSource and await in a console application (which has no SynchronizationContext). I've written simple code that waits for a ...
Hello World's user avatar
0 votes
1 answer
208 views

See below for complete minimal repro (net9 console project). When it deadlocks, and I attach a debugger, I can see that the only input task to the whenAllTask is completed, yet the whenAllTask itself ...
Balinth's user avatar
  • 578
2 votes
1 answer
137 views

Take the example below with the new Task.WhenEach method List<Task<List<int>>> tasks = [ MyTask() ]; await foreach (var task in Task.WhenEach(tasks)) { var result = await ...
schgab's user avatar
  • 696
0 votes
1 answer
86 views

I've got some code which uses AsParallel().ForAll(...) which I was led to believe would block while all of the executions completed. This works perfectly with non async code. For example the below ...
GoldieLocks's user avatar
2 votes
1 answer
190 views

I want to wrap a Task in a Task<TResult> without using an async state machine, while preserving the original task's properties. Based on What's the best way to wrap a Task as a Task<TResult&...
Ivan Petrov's user avatar
  • 7,359
0 votes
0 answers
57 views

I have an override method which looks like this: public override Task Start(CancellationToken cancellationToken) { return Task.Delay(1000,cancellationToken); } However the abstract class ...
Mr. Boy's user avatar
  • 64.5k
1 vote
3 answers
254 views

Building a basic ASP.NET Core Minimal API, I was surprised by the fact that if an endpoint returns a Task, the request does not return until the Task is done: var builder = WebApplication....
Pragmateek's user avatar
  • 13.6k
1 vote
2 answers
113 views

The doc listed the operators in the table that ToArray should be unordered when the parallelquery source is unordered. However, the result turned out to be always ordered when force evaluated to array ...
jamgoo's user avatar
  • 107
0 votes
2 answers
120 views

I'm a little bit annoyed of parentheses in situations like this: var items = (await SomeService.GetDataAsEnumerableAsync()).ToList(); So I thought of creating an extension method like: public static ...
David Ritter's user avatar
1 vote
2 answers
71 views

I was expecting Task.WaitAll to throw when semaphore reaches its maxcount, but the result is, all tasks were hanged. SemaphoreSlim semaphore = new(initialCount: 3, maxCount: 10); var tasks = ...
jamgoo's user avatar
  • 107

15 30 50 per page
1
2 3 4 5
420