tpl

Lock free constructs in .net

I am new to .net and would like to know whether .net has the java equivalent of AtomicInteger, ConcurrentLinkedQueue, etc? I did a bit of search and couldnt come up with anything. The lock free algorithms need some sort of a CAS instruction, which is provided through the undocumented Unsafe class in Java, does .net have anything equiva...

Microsoft's CCR vs Task Parallel Library

Microsoft has at least two different approches to improved support for concurrent operations. 1) Is the Concurrency Coordination Runtime (CCR) which is part of Microsoft Robotics Studio and CCR & DSS Toolkit 2) Task Paralell Library (TPL) (Part of .NET 4.0 and now in Beta 1 release) I would like to know if anyone has experience with...

Inconsistent results when executing and spawning child tasks

I have some simple code in which the main Thread is creating a new Task. The task in turn spawns multiple child tasks. The main Thread does a 'wait' on the parent Task. I'm observing that I don't get the same output across multiple runs of the program. In the code below I'm printing out the value of the iteration variable in each task bu...

Send a structure through a socket using tpl for serialization using c

After reading a few related questions I've decided to use the tpl library to serialize my structures in order to send and receive them through sockets. I'm having trouble understanding how to send and receive the tpl images using sockets. I get a segfault error on the server side when I call the tpl_dump function. I know the sockets ar...

Support of progress reporting and incremental results in .NET 4.0 "Task Parallel Library"

I know that Task Parallel Library is still in Beta and there are likely to be less resources available but from whatever I have read, library gives very special treatment to task scheduling, exception handling and cancellation. But I don't find any references to progress reporting and sending incremental results from tasks. These 2 thin...

Is there a way to tell which Tasks are currently running in Task Parallel Library

I can't see a way to see which tasks are running. There is the Task.Current property, but what if there are multiple tasks running? Is there a way to get this kind of information? Alternately, is there a built in way to get notified when a task starts or completes? ...

What's the difference of *.tpl and *.html in smarty?

I didn't find the document about this. ...

Using a hashtable inside a Parallel.ForEach??

I have a Parallel.ForEach loop running an intensive operation inside the body. The operation can use a Hashtable to store the values, and can be reused for other consecutive loop items. I add to the Hashtable after the intensive operation is complete, the next loop item can look up in the Hashtable and reuse the object, instead of runni...

What is .tpl files? php, web design

Hi guys! A man wants me to redesign a site run in PHP (VideoCMS). But when I asked him to send me the source he has given me *.tpl files instead of *.php. There is some code inside them: {include file='header.tpl' p="article"} <br /> <table width="886" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="150" valign="top...

batching remote calls (to database or service)

Hi all, Hope some of you can give some pointers on this one. I generate code where i have to make calls to remote resources like webservices or databases. Consider this piece of code class Parent{ IEnumerable<Child> Children; int SumChildren() { // note the AsParallel return Children.AsParallel().Su...

Errors with basic PHP template using eval()

I'm just about ready to cry. I have read the php.net manual page, tried a dozen Google searches with various phrases, and scanned hundreds of stackoverflow threads. I have seen this method in use, but it just doesn't work for me. It seems so basic. I have a couple related questions or problems I don't know how to find answers to. The im...

How (and if) to write a single-consumer queue using the task parallel library?

I've heard a bunch of podcasts recently about the TPL in .NET 4.0. Most of them describe background activities like downloading images or doing a computation, using tasks so that the work doesn't interfere with a GUI thread. Most of the code I work on has more of a multiple-producer / single-consumer flavor, where work items from multi...

MSDN Example of handling an exception from the TPL - Is this a race condition?

I'm looking at the TPL exception handling example from MSDN @ http://msdn.microsoft.com/en-us/library/dd537614(v=VS.100).aspx The basic form of the code is: Task task1 = Task.Factory.StartNew(() => { throw new IndexOutOfRangeException(); }); try { task1.Wait(); } catch (AggregateException ae) { throw ae.Flatten(); } My questi...

Killing a deadlocked Task in .NET 4 TPL

I'd like to start using the Task Parallel Library, as this is the recommended framework going forward for performing asynchronous operations. One thing I haven't been able to find is any means of forcible Abort, such as what Thread.Abort provides. My particular concern is that I schedule tasks running code that I don't wish to complete...

How to handle all unhandled exceptions when using Task Parallel Library?

I'm using the TPL (Task Parallel Library) in .NET 4.0. I want to be able to centralize the handling logic of all unhandled exceptions by using the Thread.GetDomain().UnhandledException event. However, in my application, the event is never fired for threads started with TPL code, e.g. Task.Factory.StartNew(...). The event is indeed fir...

How does Task Parallel Library scale on a terminal server or in a web application?

I understand that the TPL uses work-stealing queues for its tasks when I execute things like Parallel.For and similar constructs. If I understand this correctly, the construct will spin up a number of tasks, where each will start processing items. If one of the tasks complete their allotted items, it will start stealing items from the o...

Suggestions for doing async I/O with Task Parallel Library

I have some high performance file transfer code which I wrote in C# using the Async Programming Model (APM) idiom (eg, BeginRead/EndRead). This code reads a file from a local disk and writes it to a socket. For best performance on modern hardware, it's important to keep more than one outstanding I/O operation in flight whenever possibl...

Built in background-scheduling system in .NET?

I ask though I doubt there is any such system. Basically I need to schedule tasks to execute at some point in the future (usually no more than a few seconds or possibly minutes from now), and have some way of cancelling that request unless too late. Ie. code that would look like this: var x = Scheduler.Schedule(() => SomethingSomethin...

TPL contact form

I have a website that uses tpl_load for themes, and i cant figure out a way to make a contact form for it. My php pages use this for the theme files For example on my contactus.php file it would use this code for the theme. <? $content = tpl_load("contactus.html", 1, 0); ?> Does anyone know of a code of script for a simple contact ...

What are the disadvantages of using this asynchronous logging code?

Some code I just wrote follows. It demonstrates applying a PostSharp aspect to a method for the purposes of recording the duration of the method invocation in an asynchronous manner - so that if the logging process is slow then this performance penalty is not seen by the caller of the method decorated with the aspect. It seems to work...