multithreading

multithreading: how to process data in a vector, while the vector is being populated?

I have a single-threaded linux app which I would like to make parallel. It reads a data file, creates objects, and places them in a vector. Then it calls a compute-intensive method (.5 second+) on each object. I want to call the method in parallel with object creation. While I've looked at qt and tbb, I am open to other options. I plann...

c# isBackground Thread is NOT terminating properly...

I have one background thread I use for processing separately from the GUI, and everything works fine between the threads. However when I close the application, the program "closes" but does not kill the process. The background thread is keeping the program alive it seems. I have set "myThreadInstance.IsBackground = true;", and I thought...

How to debug a threadpool in Visual Studio?

I'm quite new to the multithreading environment and I'm having trouble debugging an application which makes use of a threadpool created by the elapsed event in System.Timers.timer class. I have a breakpoint set inside a method which is called each time by the elapsed event, but Visual Studio's is jumping between lines of code because it ...

Can I read and write a FIFO from concurrent threads in .NET?

I'm using a Queue<T> for caching video. The idea is to fill it with data (Enqueue), start playing (Dequeue) and fill back continously as data arrives. Can I do the filling back part from a background thread? ...

Call Method B if method A is not called for more than N seconds

I'm using following code to call Method B after N seconds method A is called. If method A is called again within the N seconds timeout, i have to reset the time counting back to N seconds. I cannot reference System.Windows.Form in my project, so I cannot use System.Windows.Form.Timer. The method B must be called in the same thread A is...

Can I change the Thread Affinity (Dispatcher) of a Control in WPF?

I want to create a control which takes a while to create (Pivot) and then add it to the visual tree. To do this i would need to change the dispatcher of the control (and its heirachy) before adding it to the VisualTree. Is this possible? Are there any implications of walking the controls trees and setting the _dispatcher field via refle...

thread write problem

i have one question. I ready many pages about best thereading like this http://www.albahari.com/threading/part4.aspx. everything is written fine, but i still have problem with threads. I run 6 threads at the same time. I am parsing some data and this data must be stored to database. But i can not store the same data twice. Now i get m...

Is this thread safe?

I am writing an application for Android and am using worker threads to process certain information. Having read through my code I am now unsure if it is thread safe. I have written a simplified version of my code, I have omitted the Handler object used to communicate with the main thread and obviously the process itself. public class m...

twisted: difference between `defer.execute` and `threads.deferToThread`

What is the difference between defer.execute() and threads.deferToThread() in twisted? Both take the same arguments - a function, and parameters to call it with - and return a deferred which will be fired with the result of calling the function. The threads version explicitly states that it will be run in a thread. However, if the defe...

How to detect if a COM application is currently running?

I have a multi-threaded application using .NET 4.0. Sometimes this COM application referenced freaks out and just stop. I want to know how to check for to see if this process is currently running within the questioned thread. Example: Exert from the main application: ThreadedApp app = new ThreadedApp(); System.Threading.Thread thre...

Reading data from a socket in ruby in a multithreaded environment

Hi chaps, I am trying to read an HTTP packet via a socket in ruby, and for some reason my code keeps on blocking whilst calling recv socket = TCPSocket.new("localhost",80) socket.send r.join("\r\n"), 0 socket.flush #We're only interested in the string "HTTP/1.1 XXX" if http_status = get_http_status(socket.recv_nonblock(12)) if http_...

Send Events to a Windows Service from Kernel Mode

I am writing a piece of software that consists of a kernel mode driver and a user mode Windows service. The kernel driver needs to notify the service of different events and information, which the service will then process. My question is this: What is the best way to set up this communication? I know it is possible to get a message ...

.NET unit test framework that can handle tests with more than one thread

Hi, I'm trying to find a unit test framework, for the .NET platform, that can handle tests with more than one thread. NUnit does not supports tests that spanws threads, since, for example, exceptions in those threads are not taked into consideration. There is an extension by Roy Osherove, but it is quite dated 1. MBUnit allows a test ...

Using threads to address memory leak in third party iphone libraries

Hello, I currently have implemented a third party library into my XCode project. The problem is that there are memory leaks which originate from the library which I found using Instruments. My question is is it possible to kick off the API function which is leaking in a separate thread using the autorelease pool in order for that thre...

Raising events so that they are handled on a the same thread as original subscriber

In dotNET with C# 4.0, How can I ensure that event that happens on an arbitrary thread X will call handlers in the same thread (or synchronization context) as the subscribing thread A, B, or C. I am trying to avoid having to put in threading-related code into handler method or event site. It would be really great if I wouldn't have to ...

c# multithreading mem usage - App slowing down and CPU usage drops.

I've got a multithreaded app that manipulates in-memory data (no database or network access). I tried this on 2 machines, one machine is Xeon dual quad core CPU, the other is twin dial-cores. 5 threads are spawned. Then this multithreaded process starts it runs very quickly and the CPU usage is at 60% for 5 cores, the physical memory is...

Android screen lock/car charger is killing my thread..

I have a very tough problem I can't solve. I have an app which I can put into airplane mode remotely to save power. I have a thread running which gets the power-save message, removes callbacks for all other threads, puts the phone into airplane mode, and waits a specified number of minutes before waking the phone back up. When the pho...

Threads, processes and Application.Exit()

My application consists of main message loop (GUI) and threads (Task.Factory). In the threads I call some 3rd party applications with var p = new Process(); But when I invoke Application.Exit(); in the message loop - I can see that the processes, that were started in the threads are still in the memory and are being executed. So the q...

Architecture for displaying dynamic data in real time

Executive summary: What kinds of sound architecture choices are there for displaying thread-safe, dynamic data in real time using Swing? Details: I have recently completed writing a multi-threaded, automated trading platform in Java. I say "platform" because I have made it very easy to implement new and multiple trading programs by su...

How can I run a specific function of thread asynchronously in c/c++?

Performance tuning: writing data to multiple pipes Now I'm doing it in a single thread: for(unsigned int i = 0; i < myvector.size();) { tmp_pipe = myvector[i]; fSuccess = WriteFile( tmp_pipe, &Time, sizeof(double), &dwWritten, NULL ); if(!fSuccess) { myvector.erase(myvector.begin()+i); printf("Client pip...