multithreading

How to parallelize Windows message loop and hook callback logic and the Ruby threads it creates?

I'm working on a free, simple, hopefully multi-platform hotkey launcher tool, written in Ruby. Right now I'm struggling with some threading issues of the Windows implementation. The rough proof of concept code shown below already works reliably in my day-to-day use: HotkeyProcessor#process_keypress (footnote 1) gets called by the C cod...

Update table with a multithreaded process and update certain rows based on priority

I have a table of customers. This table can be big, millions of rows. Every hour, I have a console app that goes through all the customers and updates another table with customer changes that occured in the last hour. What I want to do is two things: (1) Have the console app (or SSIS package) be multi-threaded so that I can have a coup...

Multi-Threading: At what point have you created too many threads?

I am working on a multi-threaded application. This application started out as a single thread and was expanded to multiple threads in order to realize a gain in performance. I have a main thread which divides up the work into smaller chunks and offloads it to worker threads which process the chunks. This portion is controlled using a ...

C# threading - Lock Object

Hi, I am trying to lock a "boxed" object in a c# app, is this not possible? class t { System.Object t_x = new object(); public t(int p) { t_x = p; } public void w() { lock (t_x) { for (int i = 0; i < 4; i++) { ...

What happens to waiting threads if I call WaitHandle.Dispose()?

I have two ManualResetEvents, which I use to pass control back and forth between two threads. Essentially a coroutine. Because the coroutine holds disposable objects (ManualResetEvents are wait handles), it should implement disposable. Also, it should dispose those ManualResetEvents when it is disposed. But, because only one thread runs...

Threading isolation in Java

Is there any sure-fire way to ensure Threads remain isolated from one-another, in Java? I've had an issue for a week and a half, where Threads implementing various 3rd party source code keep colliding due to static variables and other such things that are really beyond my control. I know a single system can run as many instances of the...

Perl Multithreaded GTK+ applet

I'd like to write a Perl GTK+ application which will: 0.1) Press button A 0.2) Disable A 0.3) start threads 1 and 2 0.4) start thread 3 Thread 3 does the following: 3.1) join thread 1 3.2) join thread 2 3.3) Enable A On completion of thread 3, the button A should be enabled again. Now, this kind of approach is perf...

Invalidating an object reference while another thread is executing a method on it (.NET)

(I'm interested in the .NET CLR) What exactly happens when one thread changes the object a variable references while another thread is executing a method on the original object? For example, say the type Foo has a variable 'Bar' of the type Bar, and Bar has no class-level state (for now at least, I'd like to keep this scenario simple)...

C# Threading issue with AutoResetEvent

How to properly synchronize this? At the moment it is possible thatSetData is called after e.WaitOne() has completed so d could be already set to another value. I tried to insert locks but it resulted into a deadlock. AutoResetEvent e = new AutoResetEvent(false); public SetData(MyData d) { this.d=d; e.Set(); // notify that ne...

sem_init(...): What is the pshared parameter for?

In a graduate class, we've had to use semaphores to accomplish work with threads. We were directed to use sem_init along with a bunch of other sem_* procedure but we were not given much information about the details of each of these sem_* methods. The prototype (and header file) of sem_init is the following: #include <semaphore.h> i...

BackgroundWorker used within collection items

I used a Backgroudworker to do some work in order to do some time consuming tasks. public void ConnectDataProvider() { bgw = new BackgroundWorker(); bgw.DoWork += new DoWorkEventHandler(bgw_DoWork); bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted); } Another method ...

WPF and databinding in a multi threaded ADO.NET app

I need advice and clarification please. I'm currently working on a monitor app that needs to show the contents of a database in a datagrid (I'm using the WPFToolkit grid btw). The grid binds to a table in my ADO.NET DataSet and it works fine. If I modify the DataSet through a button in my UI the grid updates and everyone is happy (bindin...

wait for works item to complete pooled using QueueUserWorkItem (not .NET)

I have some work items pooled using the legacy QueueUserWorkItem function (I need to support OSs earlier than vista, so for( <loop thru some items >) { QueueUserWorkItem( ) } I need to wait on these before proceeding to the next step. I've seen several similar answers...but they are in .NET. I'm thinking of using a storing an E...

Deleting pointer sometimes results in heap corruption

I have a multithreaded application that runs using a custom thread pool class. The threads all execute the same function, with different parameters. These parameters are given to the thread pool class the following way : // jobParams is a struct of int, double, etc... jobParams* params = new jobParams; params.value1 = 2; params.value2 ...

iis7 increase number of threads/concurrent requests per working process

How can I increase the number of threads/concurrent requests per working process on IIS7? I don't want to increase the number of processes to create a web garden (for now). ...

Synchronizing access to variable

I need to provide synchronization to some members of a structure. If the structure is something like this struct SharedStruct { int Value1; int Value2; } and I have a global variable SharedStruct obj; I want that the write from a processor obj.Value1 = 5; // Processor B to be immediately visible to the other proce...

Best way to obtain indexed access to a Python queue, thread-safe

I have a queue (from the Queue module), and I want to get indexed access into it. (i.e., being able to ask for item number four in the queue, without removing it from the queue.) I saw that a queue uses a deque internally, and deque has indexed access. The question is, how can I use the deque without (1) messing up the queue, (2) breaki...

Log4Net FileAppender not thread safe?

I need to log to a file because the customer doesn't have a console of something where I can log to with log4net. Now I read that the FileAppender is not thread safe. Is there anyhow a way to log to file within an app that logs out of different threads or what would be a common alternative? ...

How do I create a fixed-size ThreadPool in .NET?

Hi, I want to create a fixed arbitrary size ThreadPool in .NET - I understand the default size is 25 - but I wish to have a different size e.g. 5 or 10. Anyone? ...

Proper way in WPF MVVM to start a threaded lookup task

So I've got a task that can be preformed by my GUI that will pull information to populate a ViewModel with SQL database query response. Assume I want to start this task and keep my gui free to proceed with other things, and in the meantime play a "searching" animation, what is the proper way to do this in WPF/MVVM? I'm assuming you nee...