373 questions
0
votes
1
answer
111
views
Why are items not written to console immediately after being processed?
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 ...
1
vote
2
answers
109
views
Why do `ParallelQuery.ToArray()` and `ToList()` return ordered sequence?
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 ...
-1
votes
1
answer
220
views
How to get results from List<T>.AsParallel() in C#
I have an asynchronous
async static public Task<int> Test(int x, int y)
{
await Task.Delay(1000);
return x;
}
And I try to run it in parallele on a list. I did like that:
var x = new[] { ...
4
votes
0
answers
143
views
PLINQ behaves differently in .NET 8
Run the following code:
using System;
using static System.Console;
var numbers = Enumerable.Range(0, 31);
WriteLine("\nNumbers divisible by 5 are(using LINQ):");
numbers
.Where(num => ...
0
votes
0
answers
70
views
How to trace ETW Events inside Parallel.ForEach in C#
Need your help to understand how can we log ETW events to track Task started & Task completed inside parallel.foreach. I basically need to see when event got fired.
I have gone through few ...
2
votes
3
answers
376
views
PLINQ ForAll WithCancellation is not working
I wrote a PLINQ query that ends with the ForAll operator, and I used the WithCancellation operator in order to cancel the query midway. Surprisingly the query is not canceled. Here is a minimal ...
1
vote
1
answer
221
views
Find all the child nodes from self referenced DataTable using parent ID and update particular column on a bulk data
I have a self-referenced table like below.
key
parent
Description
A
NULL
B
A
C
B
D
C
And initially having 1 Key value.
Using this key value, I need to find all the child nodes recursively and update ...
2
votes
2
answers
396
views
Memory leak in using PLinq AsParallel
I wrote a piece of testing code using AsParallel to concurrently read big files. It causes memory leak. It seems GC doesn’t recycle the unused objects as expected. Please see the code snippet.
...
0
votes
0
answers
32
views
Conditionally use PLINQ with minimal code duplication [duplicate]
I have some LINQ code that under some conditions, which I can test for, benefits from parallelization.
I would like to use PLINQ when such conditions apply, but also avoid to have all the processing ...
0
votes
0
answers
135
views
IQueryable (PLINQ) peek and group Linq methods to run in different tasks
I want to divide a IQueryable into several ones, like the image below, extracted from the explanation of the .AsParallel(). But instead of running all in parallel, I want to run some of them together, ...
0
votes
1
answer
69
views
Can I multithread a function for all entries in a list and return the list entry that gives the max value in O(n)?
I have a list of 3D X/Y/Z points, foundPoints and single 3D X/Y/Z point, rayOrigin. I'm looking to return the point from the list that is farthest from rayOrigin. It is likely that the list could ...
3
votes
2
answers
199
views
Accessing value used in LINQ Select within a foreach
Given a list of IP addresses:
List<string> ipList = new List<string>(); //example: 192.168.0.1, 192.168.0.2, 192.168.0.3 etc.
I am attempting to loop over each IP in the list, in a ...
1
vote
1
answer
1k
views
Parallel loop containing both async and synchronous
I've got a loop that needs to be run in parallel as each iteration is slow and processor intensive but I also need to call an async method as part of each iteration in the loop.
I've seen questions on ...
1
vote
2
answers
1k
views
How to segmentate an IList<T> to segments of N size, without creating copies and without memory allocations?
I have a very large collection that implements the generic IList<T> interface and contains tens of millions of elements, and I would like to process them in parallel using PLINQ. I noticed that ...
2
votes
1
answer
1k
views
Is Task parallel library, PLINQ or Concurrent Collections used in Web Applications built with Asp.Net core Mvc or Razor Pages?
I am beginner in C# , .Net core. So, I do have very limited knowledge over this advance topics (Task parallel library, PLINQ or Concurrent Collections). If my question seemed like idiotic, then I am ...
1
vote
1
answer
2k
views
Arithmetic operation resulted in an overflow even after applying unchecked
Why do I get an overflow exception even if I apply the unchecked operator on an expression?
return GetCharStream().AsParallel().Aggregate<char, int[], int[]>(() => new int[26],
(ca, c) =&...
1
vote
0
answers
1k
views
Parallel LINQ over IAsyncEnumerable<T>?
Any official or stable 3rd party library that supports using AsParallel over an IAsyncEnumerable<T> (.NET Standard 2.1) ?
I don't want to wrap an IAsyncEnumerable<T> to an IEnumerable<...
1
vote
1
answer
686
views
Impact of using AsParallel() and AsSequential() in the same query? C#
I was going through PLINQ in one of the books and it said:
If you have a complex query that can benefit from parallel processing
but also has some parts that should be done sequentially, you can ...
0
votes
0
answers
18
views
Put a variable in plinq statement
I'm new with LINQ and I try to make a statement like this where I have a variable called status and takes a different value but how can I do this because I have this error
Error CS0029 Cannot ...
0
votes
1
answer
434
views
Plinq and linq performance comparison c#
Can someone explain for me why PLinq is better than normal linq in first example but worst in the second? I see the only difference is Thread.Sleep() at ExpensiveComputation() function
using System;
...
0
votes
1
answer
121
views
How is the PLINQ AsParallel function passing data to a function when called within the same scope
Using IronPython, I am calling some function in parallel that is within the same function the parallelized data is in to keep it in the same scope.
In multiprocessing of CPython it is pretty clear ...
0
votes
0
answers
234
views
What is the difference between ForAll and Select in PLINQ
In the intro to PLINQ, the docs seem to show two different ways of getting data back from a process unordered. In one case, AsParallel can be used with Unsorted and the Select or SelectMany method. ...
1
vote
2
answers
514
views
How to fix ArgumentException in Windows-API-Code-Pack?
I've created an application that reads properties from files using the Windows-API-Code-Pack from this package. I'm having an issue when retrieving properties
var width = fileInfo.Properties....
0
votes
2
answers
295
views
Parallel LINQ UnauthorizedAccessException when Aggregating results
I am searching in parallel using LINQ to find pattern matching files.
public class ParallelLinq
{
public IList<string> SearchFolders = new List<string>
{
@"C:\Windows" //...
1
vote
1
answer
208
views
How do I use Linq to select the top/bottom N contestants in a Ranked Choice Vote?
I am trying to use Linq (and eventually parallel Linq) calculate the top N ballots in a Ranked Choice Vote / Alternative Vote
I'm using the following code to generate several ballots with a ...