Skip to main content
Filter by
Sorted by
Tagged with
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,349
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
1 vote
2 answers
123 views

I have ~10000 objects of type System.Text.Json.JsonDocument. For each JsonDocument in parallel, I have to do the following steps in order. Clone JsonDocument to JsonNode Apply a sequence of tasks ...
lightning_missile's user avatar
0 votes
1 answer
101 views

I'm writing a console application that needs to copy console input one keypress at a time to a socket (while also doing other things). In order to do that, I figure I have a couple options. In the ...
Mark's user avatar
  • 11.8k
0 votes
2 answers
141 views

From within my ASP.NET application (.NET Framework 4.8) I invoke an external process via Anonymous Pipes. Theoretically, it could happen that the external process hangs (for whatever reason) when my ...
Jan Köhler's user avatar
  • 6,120
1 vote
1 answer
220 views

Read a lot of articles an watch many videos on Task Cancelation. But I still can't quite follow if it's possible to pass CancellationTokenSource instead of CancellationTokenSource providing that the ...
Roman Ieromenko's user avatar
1 vote
1 answer
80 views

I was expecting to trigger a AbandonedMutexException after a task that does not release the mutex, the program stuck when WaitOne after the task: Mutex mutex = new(); BankAccount account = new(); ...
jamgoo's user avatar
  • 107
0 votes
0 answers
52 views

I am in the process of building an effect system DSL with F# inspired by ZIO and Cats Effect. I have my effect type defined as a DU of opcodes, a fiber type, a channel type for message passing, etc. I ...
iyyel's user avatar
  • 55
2 votes
1 answer
109 views

I read the documentation says to set status to Canceled requires three conditions: OperationCanceledException(or its derived exception type such as TaskCanceledException) is thrown token....
jamgoo's user avatar
  • 107
1 vote
2 answers
149 views

I have a problem with AggregateException thrown from .NET library. For some reason it is not caught in try-catch block. It causes whole application to crash and there are no methods from my code in ...
Maciejosas's user avatar
1 vote
2 answers
126 views

The behavior of the non-generic Task.WhenAll changed in .NET 8, and now the order of the exceptions is in chronological order instead of positional order. The new behavior is not without merits, but I ...
Theodor Zoulias's user avatar
0 votes
0 answers
93 views

I have a communications driver. It was failing a few thousand times a day. But after changing a single line, it now works perfectly. // The event is set after 100ms at the latest ManualResetEvent ...
jeb's user avatar
  • 83.2k
0 votes
2 answers
146 views

I am writing a C# library (.NET 4.6.1) that will use Tasks to be able to run several snippets of code in the background. This library will be called by a Powershell script that is triggered from a ...
maegus's user avatar
  • 59
0 votes
1 answer
311 views

We are using the .Net Framework 4.8.2. For some part of the app I want to execute many long running CPU and IO bound processes (illustrated by Thread.Sleep()) in parallel. That's why I use the ...
theDrifter's user avatar
  • 1,716
0 votes
1 answer
72 views

Unexpected (for me) output. The code is: public static async Task Main() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int i=0; i<1000; i++) ...
Zuprik's user avatar
  • 1
0 votes
1 answer
38 views

I have a TPL DataFlow pipeline that parses msbuild project files in order to obtain the location of the respective binary and then processes these binaries. Here is how it looks like: var linkOptions =...
mark's user avatar
  • 63.6k
-2 votes
2 answers
148 views

Trying to run a Task returned by a Method and get the Result, How do you run the returned Task and get the result? using System; using System.Threading.Tasks; public class Program ...
user avatar
0 votes
3 answers
266 views

I was playing around with the ContinueWith function and I ended up not understanding it. In this example code: var s = Task.FromResult(true).ContinueWith(async t => t).ContinueWith(async t => t);...
Shuumi's user avatar
  • 193
1 vote
2 answers
128 views

I am trying to make a subclass of Task that cancels itself and waits when it is disposed. While unit testing I got strange failing test cases. In the end it boiled down to repetition; I could even run ...
GreatBarrier's user avatar
0 votes
3 answers
297 views

I have a method inside which there is a foreach loop, inside the loop I call several asynchronous operations. I asked ChatGPT to do a review, and he said that you can improve performance by adding ...
Андрей's user avatar
1 vote
0 answers
67 views

I have 2 transform blocks that are joined into a join block but I sometimes have an issue where both transform blocks finish successfully and the join block is not invoked. Relevant code snippet and ...
FMK's user avatar
  • 11
0 votes
0 answers
81 views

I don't understand clearly difference between almost following Task asynchronous code execution. Only difference is the async keyword as parameter. Example - I think this code inside Task run will ...
Jason's user avatar
  • 3
0 votes
1 answer
103 views

We use prometheus-net.DotNetMetrics for system monitoring in ASP .net6 application. And when we started using Elastic Apm agent for .net, the dotnet_exceptions_total metric began to show increased ...
Tselofan's user avatar
  • 231
0 votes
0 answers
64 views

I am writing a File Transfer Pipeline using TPL library. I am new to this types of implementation so my issue could be related to something I am not aware of. Part of my application allows users to ...
Jean's user avatar
  • 47
1 vote
1 answer
67 views

I'm trying to split big CSV files into smaller files and send them to azure storage account, all at the same. I pretty much read the big file (source) record by record and write it to a temp local ...
FEST's user avatar
  • 883
1 vote
1 answer
145 views

I have a background task that I am modeling with a Task and which is stopped with an IAsyncDisposable. // implementation public sealed class Worker : IAsyncDisposable { private readonly ...
Shane's user avatar
  • 1,216
1 vote
4 answers
173 views

I use a library that takes Task<T>, but sometimes I have to pass just Task, which I have to convert to Task<int>. What would be the more efficient/recommended option for converting the ...
fernacolo's user avatar
  • 7,469
0 votes
0 answers
968 views

I have ClassA that has a property called GetData that returns a TaskCompletionSource Task: private TaskCompletionSource<Data> _taskCompletionSource = new(); public Task<Data> GetData => ...
Flack's user avatar
  • 5,939
0 votes
0 answers
26 views

I am trying to understand how the code below would behave differently if the functions used in Task.Run were not async/await when calling GetAllData. Am I correct that GetAllData will behave the same ...
Flack's user avatar
  • 5,939
1 vote
2 answers
322 views

I have this case where I am trying to build a pipeline using TPL Dataflow that could process a big number of items. At some point in the pipeline I need to batch items and send to the next block after ...
Arturio's user avatar
  • 496
0 votes
2 answers
108 views

I am writing a plugin to Rhino which animates some ray-traced data. Rhino handles all the drawing; I just have to provide it with something to draw. The following Animate function is called from the ...
NoseHornScribe's user avatar
-1 votes
2 answers
155 views

I'm performing some element UI hit testing like this: internal MyElement[] HitTest((double x, double y) point, double scale) { ConcurrentBag<MyElement> geoms = new ConcurrentBag<...
NWoodsman's user avatar
  • 515
0 votes
2 answers
205 views

I have a use case where I need to process n number of operations, which involves other I/O operations. Method 1: Uses ConcurrentBag<T>. But worried that the I/O operations in the ...
Bobby Jose's user avatar
0 votes
0 answers
51 views

I have a multi-step, branching pipeline using TPL Dataflow, that I would like to get working with Unified Logging (through Azure Application Insights). My issue is that the APIs at my disposal (no pun ...
Andrew Matthews's user avatar
-1 votes
2 answers
92 views

I am using Task library for running multiple tasks parallelly, and I am using below code to wait for other tasks to complete. Parallel.ForEach(DatafromDB, item => { DownloadSSR(mediator, ...
Abhijith Nayak's user avatar
1 vote
3 answers
206 views

I implemented a sample application to see the behavior of the retries inside a Parallel.ForEach loop. As per my observations following application not showing all the values inside the array, in the ...
charitht99 perera's user avatar
0 votes
2 answers
1k views

I'm trying to understand async/await in .net8, especially exception handling and I'm running into some confusion, especially regarding the documentation as while it specifies some of the approach it ...
user avatar

1
2 3 4 5
126