multithreading

C# - Thread.Join(Milliseconds) and the finally block

I am using .NET 2.0 and the finally block does not seem to be getting executed if the Thread times out. For example, if I see the message "Child Thread Timed Out...", I will not see the message "Finally block started...". This means that the database objects (Oracle.DataAccess) may not be getting cleaned up properly. Is there a way to...

Timeout based concurrent queue in C++

I am trying to develop a concurrent queue using POSIX threads + C++ with the following semantics: Some threads may call push(item, timeout) and if the addition of the element does not happen by time timeout it must be rejected. Some threads may call pop(item, timeout) and again if deletion of the element does not happen by time timeou...

.NET events, threads, and messages

I understand that an event handler executes on whatever thread that invoked the event. I further understand the need to update form controls only from the thread that created the controls. I am assuming that the UI thread is the one that created the form for the purpose of this question. If the event is the result of a posted message,...

C# GUI Application, Another class from another thread updating the UI

Hello I've been researching on how to do this for about a week and I'm still not sure about the correct approach, in some examples I see the Thread class is used in others I see Invoke is used which has confused me a bid. I have a GUI program in c# which contains a textBox which will be used to give information to the user. The proble...

.NET Windows Service: Implementation of tasks - design flaw?

Hi, I am having one of those moments where I am struggling to do something neatly which automatically makes me think maybe I have got this wrong. I have a ServiceTaskManager (yes, I know people will not like the name) class: Public Class ServiceTaskManager Inherits MyAbstractClass Implements IWork, IServiceWork Public Sub...

How to queue tasks on a worker thread in Android?

Hi, I'm trying to find some simple way of queueing tasks on a thread that is NOT the UI-thread. I have a BroadcastReceiver that responds to Intents each time an image is taken, and notifies my Service each time that happens. The Service will have to do some processing (scaling and rotating an image) and I would like to do this on a new ...

Multithreading: classical Producer Consumer algorithm

Hi all, Something I don't get about the classical algorithm for the Producer-Consumer problem (from Wikipedia:) semaphore mutex = 1 semaphore fillCount = 0 semaphore emptyCount = BUFFER_SIZE procedure producer() { while (true) { item = produceItem() down(emptyCount) down(mutex) putItemIn...

Python/Tkinter: Are Tkinter StringVar (IntVar, etc) thread safe?

Are Tkinter StringVar (IntVar, FloatVar, etc) thread safe, eg. can a background thread read or write to these objects? Or must I use a Queue to pass information between my background thread and my main Tkinter GUI thread and have my main Tkinter thread pop the Queue and update the application's StringVar's accordingly? I know my applica...

Programming with SurfaceView and thread strategy for game development

Hi, I am using a SurfaceView and a rendering thread to develop a game based on structure like LunarLander. However, I faced many problems, and here I want to point them all out. I wish anyone who want to develop a game won't need to struggle with them anymore. And anyone who have a better idea of the structure can share their experienc...

How to use a QTCPServer in multiple threads?

I am trying to write a webserver that processes requests from multiple clients simultaneously. The way it is designed, only one request can be processed at a time. What I need is a way to call nextPendingConnection() and then dispatch the connection to a separate thread for processing. Is there any way to do this? ...

C# Multithread multiclass gui app, am I doing this right?

Hello I created the following project to show you guys how I plan to do things. But my main project will be bigger and will have multiple classes. I'm just trying to get this to work properly so I know I'm using good practice when coding. ok, lets begin :), so my form has a button called "button1" and a text box called "textBox1" and I...

C# Problem setting Label Content in WPF App From Separate Thread

I have a window that contains a label (player1). I also have a class that gathers data asynchronously in the background inside a thread. When that data has been gathered, I want to changed the content of my label. Since the label was created by the UI and I'm trying to edit it from another thread, I tried using Dispatcher. However, after...

[CLR Threading]When a thread pool thread blocks, the thread pool creates additional threads

I see this in the book "CLR via C#" and I don't catch it. If there are still threads available in the thread pool, why does it create additional threads? ...

Can 2 pthread condition variables share the same mutex?

I went through the documentation in http://www.opengroup.org/onlinepubs/009695399/functions/pthread_cond_wait.html but this is not mentioned explicitly. Any prompt response will be very appreciated. ...

Breakdown of Threads used by a JApplet

I've been spending a great deal of time trying to understand this. I created a JApplet that used Thread.sleep() in a loop to animate the applet. But when I tried to run the Applet the screen stayed blank. When I draw the animations in a separate thread and call repaint, the applet works perfectly. I've seen many explanations of why th...

[.net] Application.Exit raises `FormClosed` for all open forms from calling thread, generating invalid thread accesses

Hi all! My routine to check for updates is run as a separate process. Exiting the application is required to update, so a dialog asks the user, when an update is found, if they want to exit now. f they do, the code (from the update thread) calls Application.Exit(). However, if the FormClosed event of any form that needs to be closed ne...

Accessing data on another thread

Hello! I have a winform and some threads. When i try to access a field in the winform from one of the threads, the following error occurs : Cross-thread operation not valid: Control 'richTextBox1' accessed from a thread other than the thread it was created on. How can i resolve this problem? Regards, Alexandru Badescu ...

How to reactive a cancelled futuretask in thread pool ?

I use ThreadPoolExecutor to run some actions, at some time I cancelled some future tasks and stored it into a list to arrange some other tasks to do, and after that I want to reactive the saved cancelled future tasks. But the problem is when I submit the task into the pool, it would not be executed, looks like the cancelled or done flag...

Python: Cannot pop from empty list? When list is clearly not empty?

I'm obviously missing something here. Same project I've been working on for a number of days. Stepping through it bit by bit, seemed to be working fine. I added in a portion of the main() function to actually create the comparison lists, and suddenly starts throwing out cannot pop from empty list error at me, even through a print functio...

boost::thread and template functions

I am trying to run a template function on a separate thread but IntelliSense (VC++ 2010 Express) keeps giving me the error: "Error: no instance of constructor "boost::thread::thread" matches the argument list" and if I try to compile I get this error: "error C2661: 'boost::thread::thread' : no overloaded function takes 5 arguments" The ...