plinq

How do Reactive Framework, PLINQ, TPL and Parallel Extensions relate to each other?

百般思念 提交于 2019-11-28 02:46:18
At least since the release of .NET 4.0, Microsoft seems to have put a lot of effort in support for parallel and asynchronous programming and it seems a lot of APIs and libraries around this have emerged. Especially the following fancy names are constantly mentioned everywhere lately: Reactive Framework, PLINQ (Parallel LINQ), TPL (Task Parallel Library) and Parallel Extensions. Now they all seem to be Microsoft products and they all seem to target asynchronous or parallel programming scenarios for .NET. But it is not quite clear what each of them actually is and how they are related to each

Why does PLINQ use only two threads?

穿精又带淫゛_ 提交于 2019-11-27 18:39:09
问题 Say I have an IO-bound task. I'm using WithDegreeOfParallelism = 10 and WithExecution = ForceParallelism mode, but still the query only uses two threads. Why? I understand PLINQ will usually choose a degree of parallelism equal to my core count, but why does it ignore my specific request for higher parallelism? static void Main(string[] args) { TestParallel(0.UpTo(8)); } private static void TestParallel(IEnumerable<int> input) { var timer = new Stopwatch(); timer.Start(); var size = input

How to properly parallelise job heavily relying on I/O

大城市里の小女人 提交于 2019-11-27 11:42:34
I'm building a console application that have to process a bunch of data. Basically, the application grabs references from a DB. For each reference, parse the content of the file and make some changes. The files are HTML files, and the process is doing a heavy work with RegEx replacements (find references and transform them into links). The results in then stored on the file system and sent to an external system. If I resume the process, in a sequential way : var refs = GetReferencesFromDB(); // ~5000 Datarow returned foreach(var ref in refs) { var filePath = GetFilePath(ref); // This method

Difference linq and plinq

可紊 提交于 2019-11-27 07:42:19
问题 What is the difference between these two? What is the best way to compare ? It is always better plinq ? When we use plinq ? 回答1: Linq is a collection of technologies that work together to solve a similar family of problems - in all of them you have a source of data (xml file or files, database contents, collection of objects in memory) and you want to retrieve some or all of this data and act on it in some way. Linq works on the commonality of that set of problems such that: var brithdays =

When to dispose CancellationTokenSource?

人走茶凉 提交于 2019-11-27 02:58:49
The class CancellationTokenSource is disposable. A quick look in Reflector proves usage of KernelEvent , a (very likely) unmanaged resource. Since CancellationTokenSource has no finalizer, if we do not dispose it, the GC won't do it. On the other hand, if you look at the samples listed on the MSDN article Cancellation in Managed Threads , only one code snippet disposes of the token. What is the proper way to dispose of it in code? You cannot wrap code starting your parallel task with using if you do not wait for it. And it makes sense to have cancellation only if you do not wait. Of course you

How do Reactive Framework, PLINQ, TPL and Parallel Extensions relate to each other?

只谈情不闲聊 提交于 2019-11-26 23:48:31
问题 At least since the release of .NET 4.0, Microsoft seems to have put a lot of effort in support for parallel and asynchronous programming and it seems a lot of APIs and libraries around this have emerged. Especially the following fancy names are constantly mentioned everywhere lately: Reactive Framework, PLINQ (Parallel LINQ), TPL (Task Parallel Library) and Parallel Extensions. Now they all seem to be Microsoft products and they all seem to target asynchronous or parallel programming

How to properly parallelise job heavily relying on I/O

风格不统一 提交于 2019-11-26 18:03:56
问题 I'm building a console application that have to process a bunch of data. Basically, the application grabs references from a DB. For each reference, parse the content of the file and make some changes. The files are HTML files, and the process is doing a heavy work with RegEx replacements (find references and transform them into links). The results in then stored on the file system and sent to an external system. If I resume the process, in a sequential way : var refs = GetReferencesFromDB();

When to dispose CancellationTokenSource?

荒凉一梦 提交于 2019-11-26 09:06:52
问题 The class CancellationTokenSource is disposable. A quick look in Reflector proves usage of KernelEvent , a (very likely) unmanaged resource. Since CancellationTokenSource has no finalizer, if we do not dispose it, the GC won\'t do it. On the other hand, if you look at the samples listed on the MSDN article Cancellation in Managed Threads, only one code snippet disposes of the token. What is the proper way to dispose of it in code? You cannot wrap code starting your parallel task with using if