multithreading

C# Running IronPython On Multiple Threads

I have a WPF app that controls audio hardware. It uses the same PythonEngine on multiple threads. This causes strange errors I see from time to time where the PythonEngines Globals dictionary has missing values. I am looking for some guidance on how to debug/fix this. The device has multiple components [filter's, gain's, etc.]. Each co...

Can anyone show a sample of two threads reading messages from a Queue(of String)?

I'm trying to improve performance of an application by introducing threading (see my earlier question). I have filled a Queue(of String) with XML messages and I now want to setup two threads to post these messages to a webserver). This process needs to ensure that each message is only posted once. Would a BackgroundWorker (or two) be sui...

WaitHandle.WaitAny() & WaitHandle.WaitAll() usage problem...

My application is not exiting properly. I am just trying to print the total number of connections, after that waiting for all the upload operations to complete, and then quit gracefully. Below is the code... using System; using System.Net; using System.Threading; using System.IO; using System.Text; namespace ServicePointDemo { cla...

ASP.net web services

I am using a web service which sets the Thread.CurrentPrincipal object while logging in and soon later when another webmethod of the same web service accesses Thread.CurrentPrincipal, its different/resets Can someone tell me if this is expected or can different webmethod calls from the same client can access the same Thread.CurrentPrinc...

How do I prevent duplicate headers when dealing with threads in PHP?

I've written a PHP script that has to fork and do some processing in parallel, and then the main page returns data after processing. I'm currently using the pcntl functions to do this. I need to run anywhere between 2 and 10 threads to work in parallel, and I have to wait until I get a result from all of the threads before the script out...

Why is SynchronizationContext.Current null in my Winforms application?

I just wrote this code: System.Threading.SynchronizationContext.Current.Post( state => DoUpdateInUIThread((Abc)state), abc); but System.Threading.SynchronizationContext.Current is null ...

Determine thread which holds the lock on file

Hi, I know there is no WINAPI which would do it, but if a thread is hung and holds an open handle of file. how do we determine the thread id and Terminate it within our processes. I'm not talking about releasing file locks in other processes but within my own process. it could also be possible that thread has crashed / terminated with...

Background Worker Updates a ProgressBar partially or not all Then Bombs Out !!!

Hi guys, A while ago I asked for some help about setting up a progress bar to show to the user how much progress has been made on the given set of files and folders. See here: First Attempt At Background worker. As a result I managed to get it to work but on some occasions it partially fills up and sometimes not at all. Exiting with ...

Multithreading: Read from / write to a pipe

I write some data to a pipe - possibly lots of data and at random intervals. How to read the data from the pipe? Is this ok: in the main thread (current process) create two more threads (2, 3) the second thread writes sometimes to the pipe (and flush-es the pipe?) the 3rd thread has infinite loop which reads the pipe (and then sleeps ...

C++ Threadsafe Singleton (NOT FOR INIT)

So I want to access a singleton class from multiple threads. Conceptually I'd think that calling non-const methods on this singleton instance would be not thread-safe. I've been looking online and no one seems to address this possible issue. Is there an actual problem with this, is the only issue with Singleton's thread-safety, the initi...

Implement atomic increment using atomic swap?

Suppose I'm writing (assembly) code for a CPU whose only atomic operation is an unconditional swap -- no LL/SC, no compare-and-swap, just plain swap. (An ARM9 would be an example of such a beast.) Is there a way to perform atomic increment/decrement operations using the swap operation? There is a relatively easy answer, which is to use ...

c library function to get number of active threads

Hi everybody, I'm developing a multi threaded Unix application in C. Is there a simple way to get the count of the number of simultaneously active threads? I don't want to have to write the code to keep track of the number of active thread if it already can be done for me by the library! :-) I'm using POSIX pthreads, and I'm trying to ...

Threads & Processes Vs MultiThreading & Multi-Core/MultiProcessor : How they are mapped?

I was very confused but the following thread cleared my doubts: Multiprocessing, Multithreading,HyperThreading, Multi-core But it addresses the queries from the hardware point of view. I want to know how these hardware features are mapped to software? One thing that is obvious is that there is no difference between MultiProcessor(=Mut...

Can XSLT processors be multi-threaded?

Hi everyone, I'm fishing for approaches to a problem with XSLT processing. Is it possible to use parallel processing to speed up an XSLT processor? Or are XSLT processors inherently serial? My hunch is that XML can be partitioned into chunks which could be processed by different threads, but since I'm not really finding any documentat...

Testing simultaneous calls to transactional service

How should I test a service method that is transactional for its simultaneous use (it updates a database row by decreasing a value)? I have setup a JUnit test class with SpringJunit4ClassRunner and components are @autowired. Just spawning threads which would call the method doesn't seem to work. I'm not sure whether this has something ...

boost::thread exit code?

What is the standard way to get an exit code from a boost::thread ? The docs don't seem to touch on this subject at all. ...

Alternating pPicture boxes with updating images stop showing on form after a while

Hi, I've got two pictureboxes in a windows form which are assigned a new image in a separate thread, then are made visible to the windows form. So if we had two pictureboxes, A and B, if A is visible with an image on, B is invisible and a bitmap is loaded from a file and is assigned on the image property of B on a separate thread, then ...

get number of CPUs in C++ MFC application

Hi! I write a little raytracer and i'd like to query how many cpu cores (or virtual cpu cores if the cpu uses hyperthreading) the current computer offers, such that i can instanciate as many threads to get better parallel rendering. How can I do that using C++? thanks! ...

Why doesn't Thread implement IDisposable?

I noticed that System.Threading.Thread implements a finalizer but not IDisposable. The recommended practice is to always implement IDisposable when a finalizer is implemented. Jeffrey Richter wrote that the guideline is "very important and should always be followed without exception". So why doesn't Thread implement IDisposable? It seem...

Is the following utility class thread-safe?

First let's look at the utility class (most javadoc has been removed to simply the example): public class ApplicationContextUtils { /** * The application context; care should be taken to ensure that 1) this * variable is assigned exactly once (in the * {@link #setContext(ApplicationContext)} method, 2) the context is...