I am trying to use the NET 4.0 parallel task library to handle multiple FTS queries. If the query takes too much time, I want to cancel it and continue forward with processing the rest.
This code doesn't stop when one query goes over the threshold. I think I'm calling it such that the cancel task and time limit is reached for the whol...
Currently stuck in C# 2, it would still be nice to use the parallel goodness of the TPL... is this possible?
...
I made a program to test Parallel programming in C# 4.0. However, there is a problem and I can't figure out why.
I write a method
private void compute(int startValue, int endValue, ConcurrentBag<Pair> theList)
{
try
{
Task computation = Task.Factory.StartNew(() => { findFriendlyNumbers(startValue, en...
What would be the best approach for implementing Tasks with a KEY that operate as follows:-
Option 1) Only one of this key is ever pending. Can be used, for example, from ASP.NET MVC to queue up a single render for a thumbnail image no matter how many times the image Url is hit. Only one runs, all other requests wait for that one to c...
I want to display a image onclick on a text 'zoomimage' in a 'tlp'.So, please can you help me to make it. The image is already in a folder name 'images', it should be displayed by using ajax.
Thank you
...
I am developing an application that has the potential for massive parallel processing.
Currently, I am using a single PC with 8 cores, but I need to support distributed computing.
TPL Constructs such as PLINQ and Parallel.ForEach could be used to naturally distribute work load between different threads.
How could they be made to distrib...
I'm attempting to programmatically chain asynchronous operations in C#4, such as Writes to a given Stream object. I originally did this "manually", hooking callbacks from one operation to the next, but I thought I'd try the .NET 4 Task Parallel Library to save myself the trouble of re-inventing the concurrent wheel.
To start with, I wra...
Is there a shorter way to wait for multiple threads to finish? Maybe using ContinueWhenAll... but I don't want to run the rest of my code async.
List<object> objList = // something
List<Task> taskHandles = new List<Task>();
for(int i = 0; i < objList.Count; i++) {
taskHandles.Add(Task.Factory.StartNew(() => { Process(objList[i]);...
Hello all, I'm trying to use tpl to serialize structs that contain wchar_t* strings.
The code I have looks like this, and it's not working:
#include <stdio.h>
#include <locale.h>
#include <string.h>
#include <wchar.h>
#include "tpl.h"
struct chinese_t {
wchar_t *chars;
};
int main() {
tpl_node *tn;
struct chinese_t cstr;
cstr...
I'm working on a project that creates like 20~50 new tasks every 30~80 seconds.
Each task lives for 10~20 seconds.
So I'm using a Timer to create those new tasks, but everytime I always recreate the same task, the code is like this:
public class TaskRunner : IDisposable
{
private readonly Timer timer;
public IService service;
...
Certain System.Threading.Tasks.Task constructors take a CancellationToken as a parameter:
CancellationTokenSource source = new CancellationTokenSource();
Task t = new Task (/* method */, source.Token);
What baffles me about this is that there is no way from inside the method body to actually get at the token passed in (e.g., nothing l...
Since .NET 4.0 there is the TPL to execute asynchronous tasks. If you are reading the msdn, all async operations interacting with forms / UI still uses the InvokeRequire ... Invoke() pattern.
What I'm asking is that is there a reason for it? From what I learned, TPL should be sort of a replacement of older threading mechanisms. So what's...
Hi there,
I've a two while loops, which I will have run parallel with the TPL.
My code :
public void Initialize()
{
cts = new CancellationTokenSource();
ParallelOptions options = new ParallelOptions();
options.CancellationToken = cts.Token;
options.MaxDegreeOfParallelism = Environment.ProcessorCount;
task = Task.Fac...
I am looking for a tool that will allow me to execute unit tests over all possible interleavings (spelling?) with a program that was written with Task Parallel Library constructs. Alternatively, how could I run CHESS with dotNET 4.0?
...
Firstly, my scenario:
An application with data input, data processing and result aggregation. Input data can be huge so it is cut into batches. Batches are individual. Data processing becomes batch processing and is a relatively time-consuming procedure. Finally, each batch processing would result in a batch result. All batch results ar...
I'd like to speed-up the indexing of 10GB of data into a Lucene index. Would TPL be a good way to do this? Would I need to divided the data up into chunks and then have each thread start indexing chunks?
To keep the UI responsive would BackgroundWorker be the best approach, or Task, or something else?
Does SOLR already do something l...
Imagine you are utilizing Parallelism in a multi-core system.
Is it not completely possible that the same instructions may be executed simultaneously?
Take the following code:
int i = 0;
if( blockingCondition )
{
lock( objLock )
{
i++;
}
}
In my head, it seems that it is very possible on a system with multiple cores a...
I have a following fairly simple scenario:
Some data needs to be written into a DB (pretty big collection) that can be partitioned. But I have two problems:
Easy one: would like to have an option to print the progress bar, so that would like to know how many records have been inserted so far from time to time (kinda shared counter amon...
I hope this is not a misuse of stackoverflow; recently I've seen some great questions here on Parallel Extensions, and it got my interest piqued.
My question:
Are you using Parallel Extensions, and if so, how?
My name is Stephen Toub and I'm on the Parallel Computing Platform team at Microsoft. We're the group responsible for Parallel...
I want to convert a for loop which increments the iterator by 2 every pass into a Parallel For loop using the TPL. The data is not order dependent or constrained in any way, but I only want to process the data in every other element of my source array (which is _Datalist in the code below), hence the need to increment by 2.
My For Loop:...