task-parallel-library

Is it possible to fire 3000 parallel asynchronous HTTP requests from ASP.NET core Controller?

ぐ巨炮叔叔 提交于 2019-12-25 19:05:37
问题 I have a web API controller that receives a filter object from the front-end. The filter basically is just a json array of objects that contains the filtering criteria. Now based on that filter I have to run a query against an azure API (Azure log analytics api). This is illustrated in this code snippet : var tasks = filters.Select(filter=> { try { return service.GetPerformanceCounters(filter.SComputerId, filter.WorkSpace); } catch (Exception ex) { return Task.Run(() => new List<Metrics>());

Is it possible to fire 3000 parallel asynchronous HTTP requests from ASP.NET core Controller?

孤人 提交于 2019-12-25 19:05:36
问题 I have a web API controller that receives a filter object from the front-end. The filter basically is just a json array of objects that contains the filtering criteria. Now based on that filter I have to run a query against an azure API (Azure log analytics api). This is illustrated in this code snippet : var tasks = filters.Select(filter=> { try { return service.GetPerformanceCounters(filter.SComputerId, filter.WorkSpace); } catch (Exception ex) { return Task.Run(() => new List<Metrics>());

Why I get duplicated values during a Parallel Task Execution using an Iterator?

走远了吗. 提交于 2019-12-25 14:04:42
问题 I want retrieve a list of unique customer Ids from a simple XML file (see below), using Task Parallel Library (TPL). I use XPathNavigator to iterate through xml and retrieve customer Ids. I’m using an iterator with the Parallel.ForEach(..) for task parallelism. For some reason I retrieve duplicated customer Ids . It almost seems like the iterator keeping track of previous reads/iteratoes. I’m expecting new iterator each time when I loop through. I have tried number of ways still no luck. If

Task based processing with a limit for concurrent task number with .NET 4.5 and c#

不羁的心 提交于 2019-12-25 06:59:32
问题 Following this, could anyone post a barebone solution for the following task, targeting .NET 4.5 (and WPF UI on a bigger scale)? Basically I'm looking for a functional analog of any torrent application implemented on .NET 4.5 and c#. The task: I have IEnumerable<IProcessable> , containing 1000 instances of IProcessable , IProcessable has Process(int argument) method, taking from 1 to 10 seconds to execute. I want to loop through the collection and process each instance of IProcessable ,

How do I make this run asynchronously?

你离开我真会死。 提交于 2019-12-25 05:35:49
问题 I am writing a WPF application in C# and in it I need to query history in TFS, and I'm displaying the list of changesets I get back in a listview. The listview ItemsSource is bound to an IEnumerable property called Changesets that is not loaded until the property is used: public IEnumerable<Changeset> Changesets { get { if (p_nChangesets == null) { p_nChangesets = TfsHelper.VCS.QueryHistory(Path, VersionSpec.Latest, 0, RecursionType.Full, null, new ChangesetVersionSpec(1), VersionSpec.Latest,

Task.IsCompleted stays false even when CancelIsRequested

可紊 提交于 2019-12-25 05:31:57
问题 In my LogManager, I have an async task that runs a while loop to write log information to a text file (and add it to a collection). When I try to cancel this task, the loop seems to stop (I tried with several Console.WriteLines), but the task however doesn't complete. Here are the main methods of this class: public static DateTime StartTime; private static CancellationTokenSource SaveLoopToken; private static Task SaveLoopTask; public static void Start() { LogMessage startMessage = new

PLINQ query, need to know how many iterations performed

时光总嘲笑我的痴心妄想 提交于 2019-12-25 05:18:28
问题 what I'm basically doing is iterating in parallel over a sequence of letter combinations, when I get the combo I want it's considered a win. I want to get all the wins from this query (which it's doing correctly), but the trick has been how to keep track of the number of times the test for a win was executed (basically the method that returns true/false that it won). I'm creating an instance variable in the class that increments each time the test on the combo is performed, but each time I

Async Logger. Can I lose/delay log entries?

徘徊边缘 提交于 2019-12-25 05:16:06
问题 I'm implementing my own logging framework. Following is my BaseLogger which receives the log entries and push it to the actual Logger which implements the abstract Log method. I use the C# TPL for logging in an Async manner. I use Threads instead of TPL. (TPL task doesn't hold a real thread. So if all threads of the application end, tasks will stop as well, which will cause all 'waiting' log entries to be lost.) public abstract class BaseLogger { // ... Omitted properties constructor .etc. ..

Single source producer to multiple cosumers working in parallel

筅森魡賤 提交于 2019-12-25 04:55:11
问题 I want to have a kind of queue in which a single source inputs data in it and on the other side there will be consumers waiting that when they detect that the queue is not empty will start to execute the data until they are halted. but its important that if the queue is emptied they will still remain watching the queue such that if more data pops in they will be able to consume it. What i found By multiple consumer and multiple producers as the consumers are nested in the producers where in

Cancel current synchronous request processing

我只是一个虾纸丫 提交于 2019-12-25 01:03:31
问题 I am trying to cancel current request made by user. Web Forms Web App have export to excel feature. If it takes long time to generate excel report user can cancel the request. Once the cancel button is clicked the server should stop processing to save precious bandwidth. I have found two solutions as listed below. First Solution: Prevent further code from executing by jumping straight to the Application_EndRequest event. protected void btnCancel_Click(object sender, EventArgs e) { if