I have a WinForms C# program where I will have up to 1 million business objects open at once (in memory) on the user's machine. My manager has asked for a real simple filter on these business objects. So if you filter on "Fred", the user will be shown a list of all objects which contains "Fred" in any of the text fields (Name, Address, Contact person etc). Also, this n
我有一个WinForms C#程序,我将在用户的机器上一次打开(在内存中)一百万个业务对象。 我的经理要求对这些业务对象进行真正简单的过滤。 因此,如果您在“Fred”上过滤,用户将在任何文本字段(姓名,地址,联系人等)中显示包含“Fred”的所有对象的列表。 此外,这需要尽可能接近实时而不会阻塞用户界面。 因此,如果您在过滤器文本框中输入“Fred”,只要键入“F”,搜索将开始在任何文本字段中查找带有“F”的结果(我想我可能
I have few hundreds of files i need to upload to Azure Blob Storage. I want to use parallel task library. But instead of running all the 100 threads to upload in a foreach on list of files, how can i put a limit on max number of threads that it can use and finish the job in parallel. or does it balance the things automatically? You should not be using threads for this at all. There's
我有几百个文件需要上传到Azure Blob存储。 我想使用并行任务库。 但是,如何在文件列表中以foreach的形式运行所有100个线程,我怎么能限制它可以使用的线程的最大数量并且并行完成作业。 还是它会自动平衡事情? 你根本不应该使用线程。 有一个基于Task的API,它自然是异步的:CloudBlockBlob.UploadFromFileAsync。 在async/await和SemaphoreSlim使用它来限制并行上传的数量。 示例(未测试): const MAX_PARALLEL
I'm trying to figure out a good way to do parallelization of code that does processing of big datasets and then imports the resulting data into RavenDb. The data processing is CPU bound and database import IO bound. I'm looking for a solution to do the processing in parallel on Environment.ProcessorCount number of threads. The resulting data should then be imported into RavenDb on x
我试图找出一种很好的方法来完成处理大数据集的代码的并行化,然后将结果数据导入到RavenDb中。 数据处理是CPU绑定和数据库导入IO绑定。 我正在寻找一种解决方案来并行处理Environment.ProcessorCount线程数量。 然后将结果数据导入RavenDb的x(可以说10个)并行线程与上述过程并行。 这里主要的是我希望处理在导入完成数据时继续,以便在等待导入完成时继续处理下一个数据集。 另一个问题是每个批次的内存需要在成功导
I have a million elements in a List to process. Dropping them crudely into a Parallel.ForEach would just saturate the CPU. Instead I split the Elements Master Lists into pieces and drop the Sublists into a parallel loop. List<Element> MasterList = new List<Element>(); Populate(MasterList); // puts a Million elements into list; //Split Master List into 100 Lists of 10.0000 elemen
我在List中要处理一百万个元素。 粗暴地将它们拖放到Parallel.ForEach中会使CPU饱和。 相反,我将元素主表分成几部分,并将子列表放入并行循环中。 List<Element> MasterList = new List<Element>(); Populate(MasterList); // puts a Million elements into list; //Split Master List into 100 Lists of 10.0000 elements each List<List<Element>> ListOfSubLists = Split(MasterList,100); fo
public static void RemoveAllNetworkPrinters() { ManagementScope oManagementScope = new ManagementScope(ManagementPath.DefaultPath); oManagementScope.Connect(); SelectQuery oSelectQuery = new SelectQuery(); oSelectQuery.QueryString = @"SELECT * FROM Win32_Printer WHERE ServerName IS NOT NULL"; using (ManagementObjectSearcher oObjectSearcher = new Ma
public static void RemoveAllNetworkPrinters() { ManagementScope oManagementScope = new ManagementScope(ManagementPath.DefaultPath); oManagementScope.Connect(); SelectQuery oSelectQuery = new SelectQuery(); oSelectQuery.QueryString = @"SELECT * FROM Win32_Printer WHERE ServerName IS NOT NULL"; using (ManagementObjectSearcher oObjectSearcher = new Ma
I never tried parallel programming before in c#. So, before I jumped in, I wish I can get a fast answer to know if it worth delving into it, or not. I have C# WCF web services applications with .NET 4.0. (it is possible to upgrade to 4.5 if parallel programming works) All services are REST Services. There is one service in particular that is taking sometimes very long time. The service is
我从来没有在c#中尝试过并行编程。 所以,在我跳入之前,我希望我能得到一个快速答案,以了解它是否值得深入研究。 我有.NET 4.0的C#WCF Web服务应用程序。 (如果并行编程有效,可以升级到4.5) 所有服务都是REST服务。 有一种服务特别有时需要很长时间。 该服务正在处理和修改一个xml文档。 该服务接受一个xml字符串作为输入,并返回修改后的xml文件。 该服务在不同的位置和不同的元素处理xml。 所以,我创建了一
I have an external singlethreaded program that needs to be run multiple hundred times with different parameters. To make it faster I want to run it once for each core at the same time. To do that I used Parallel.ForEach running on a list with the different parameters to pass to the external program: var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorC
我有一个外部单线程程序,需要使用不同的参数运行数百次。 为了让它更快,我想同时为每个内核运行一次。 为此,我使用运行在具有不同参数的列表上的Parallel.ForEach传递给外部程序: var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount // 8 for me }; Parallel.ForEach(ListWithAllTheParams, parallelOptions, DoTheStuff); ... private void DoTheStuff(ParamType
I'm using C# Parallel.ForEach to process more than thousand subsets of data. One set takes 5-30 minutes to process, depending on size of the set. In my computer with option ParallelOptions po = new ParallelOptions(); po.MaxDegreeOfParallelism = Environment.ProcessorCount I'll get 8 parallel processes. As I understood, processes are divided equally between parallel tasks (eg the first
我使用C#Parallel.ForEach来处理超过数千个数据子集。 一套需要5-30分钟才能处理,具体取决于套装的尺寸。 在我的电脑上有选项 ParallelOptions po = new ParallelOptions(); po.MaxDegreeOfParallelism = Environment.ProcessorCount 我会得到8个并行进程。 据我了解,流程在平行任务之间平均分配(例如,第一项任务获得1,9,17等职位,第二项获得2,10,18等); 因此,一项任务可以比其他任务更早完成自己的工作。 因为这
This is an "is this possible, and if so can you give me a quick example because I can't find one online?" kind of question. I have a number of completely separate (ie "embarrassingly parallel") processes that I want to run in parallel using the Task Parallel library in .NET Framework 4 using C#. Some of these processes require the use of software that can be accessed v
这是“这是可能的,如果是这样,你能给我一个快速的例子,因为我找不到一个在线?” 有种问题。 我有许多完全独立的(即“尴尬的并行”)进程,我想使用C#使用.NET Framework 4中的任务并行库并行运行。 其中一些过程需要使用可通过COM / OLE自动化访问的软件。 具体来说,有一个Parallel.Foreach()循环,它将项目列表中的任务分开,基本上调用了Parallel.Foreach中的一个不同的函数来处理处理(因此其中一些函数使用COM库
Can you explain Liskov Substitution Principle (The 'L' of SOLID) with a good C# example covering all aspects of the principle in a simplified way? If it is really possible. (This answer has been rewritten 2013-05-13, read the discussion in the bottom of the comments) LSP is about following the contract of the base class. You can for instance not throw new exceptions in the sub clas
你能用一个很好的C#例子来解释Liskov替换原理(SOLID的'L')吗?它以简单的方式涵盖了原理的所有方面? 如果真的有可能。 (这个答案已被改写2013-05-13,阅读评论底部的讨论) LSP是关于遵循基类的契约。 你可以例如不要在子类中抛出新的异常,因为使用基类的人不会期望这样。 如果基类抛出ArgumentNullException如果缺少参数并且子类允许参数为空(也是LSP违例),则也是如此。 下面是一个违反LSP的类结构