multithreading

Implement thread-safe collection for data-binding in .NET

I have a Windows Forms application that displays a form with a DataGridView bound to a custom collection that inherits BindingList. I'm using the BindingSource / DataSource mechanism for data-binding. The form is a monitor that displays status information contained in the collection. Each element of the collection represents status in...

Preventing multithreaded apps from running out of memory

I've written a small, in house C# program which batch converts between various file formats, mostly relying on other API's. Currently, the UI spawns a BackgroundWorker (not a Thread) to handle the conversions, and then fills a queue with the requests which empties as the worker completes jobs. The queue object themselves are very small...

Locking details of synthesized atomic @properties in Obj-C 2.0

The documentation for properties in Obj-C 2.0 say that atomic properties use a lock internally, but it doesn't document the specifics of the lock. Does anybody know if this is a per-property lock, a per-object lock separate from the implicit one used by @synchronized(self), or the equivalent of @synchronized(self)? ...

Are asynchronous Django model queries possible?

I'm new to Django, but the application that I have in mind might end up having URLs that look like this: http://mysite/compare/id_1/id_2 Where "id_1" and "id_2" are identifiers of two distinct Model objects. In the handler for "compare" I'd like to asynchronously, and in parallel, query and retrieve objects id_1 and id_2. Is there a...

This class uses AtomicBooleans. Is it thread safe ?

I don't like to lock up my code with synchronized(this), so I'm experimenting with using AtomicBooleans. In the code snippet, XMPPConnectionIF.connect() makes a socket connection to a remote server. Note that the variable *connecting is only ever used in the connect() method; whereas *connected is used in every other methods that needs t...

Is accessing to different indexes of a TObjectList thread safe?

I have a TObjectList that needs to be processed by several threads. Since internally TObjectList inherits from TList and TList implements its internals as an array I wonder: Is it thread safe to access the array from different threads as long as we access different indexes? For example, having a TObjectList called myObjectList: start ...

How to find a thread id in Python

I have a multi-threading Python program, and a utility function, writeLog(message), that writes out a timestamp followed by the message. Unfortunately, the resultant log file gives no indication of which thread is generating which message. I would like writeLog() to be able to add something to the message to identify which thread is ca...

App Verifier reporting "Thread cannot own a critical section."

So App Verifier is throwing this exception. From what I gather, the text of this message is a little misleading. The problem appears to be that the the critical section was created by a thread that is being destroyed before the critical section is destroyed. It's a relatively simple fix but does anyone know what the ramifications ar...

Asynchronous screen update to gameplay logic, C++

Hello. I am programming a game using Visual C++ 2008 Express and the Ogre3D sdk. My core gameplay logic is designed to run at 100 times/second. For simplicity, I'll say it's a method called 'gamelogic()'. It is not time-based, which means if I want to "advance" game time by 1 second, I have to call 'gamelogic()' 100 times. 'gamelogic()'...

C# Windows Form created by EventHandler disappears immediately

I don't know why this is happening, but when I create a new form inside an EventHandler, it disappears as soon as the method is finished. Here's my code. I've edited it for clarity, but logically, it is exactly the same. static void Main() { myEventHandler = new EventHandler(launchForm); // Code that creates a thread which cal...

Block while waiting for event

Hi, I have an external COM-object that connects to a server and then fire an event when the server is ready. The connect() call is thus asynchronously. My code looks (a bit...) like ManualResetEvent waitConnection; //This is the event that is triggered when server is ready public void onConnection_event(bool success) { if(success...

How to detect cross thread access in .NET (enforce thread affinity)?

I'm writing a special data structure that will be available in a .NET library and one of the features of this data structure is that is will be thread safe provided that only one thread writes data to it, and only one thread reads data from it (the reader thread and the writer thread can be different). The question is how can I enforce ...

Using gprof with pthreads

Can gprof be used to profile a multi-threaded program that uses pthreads? That is, will its output include the time used in all the threads? ...

C# thread safety of global configuration settings

In a C# app, suppose I have a single global class that contains some configuration items, like so : public class Options { int myConfigInt; string myConfigString; ..etc. } static Options GlobalOptions; the members of this class will be uses across different threads : Thread1: GlobalOptions.myConfigString = ...

When should I use each of Android's different messaging types?

Hi, I've been working with Android for well over a year now, but I still have trouble determining when different types of messaging/communication between processes/threads should be used. I'm mainly talking about broadcasting Intents, using AIDL for services, using Handlers to send messages and socket communication. Many of these tools...

Threads shutdown during mixed managed/unmanaged c++/CLI process shutdown

I'm working on a mixed managed/native application using c++/CLI. I know that the CLR will suspend all managed threads on (a clean) shutdown, but what about the unmanaged ones? Is it possible for the unmanaged threads to still be running, while the CLR runtime is shutting down/freeing memory/running finalizers? ...

Running a separate process or thread in Qt

I'm writing my first proper useful piece of software. Part of it will involve the user viewing an image, and choosing to accept or reject it. Doing this will cause the image to be saved to an accepted or rejected folder, and possibly rotated and/or resized. At the moment, my rotate/resize/save operation is pausing execution of my progra...

How can I make a piece of code run in a separate thread?

I have a few method calls like this: [self myFoo]; [self heavyStuff]; // this one in other thread [self myBar]; which classes / methods do I have to look at? When I search for "thread", there comes a lot of classes, methods and functions. Which one's are most apropriate here? ...

Event / Task Queue Multithreading C++

I would like to create a class whose methods can be called from multiple threads. but instead of executing the method in the thread from which it was called, it should perform them all in it's own thread. No result needs to be returned and It shouldn't block the calling thread. A first attempt Implementation I have included below. The ...

Updating a Progress Bar from Another Thread

I have a windows form on the main thread and another thread that does some calculations. I'd like to update the status bar on my form from the work being done in the other thread. What's the best way to do this? So far everything I've tried just makes things run really slowly. I'm using Visual Studio 2005. ...