multithreading

Dude, where's my thread?? (or: rename a .NET thread pool thread - is it possible?)

Sometimes I find myself stepping through an application in Debug mode, until I hit 'step' on some particular line and it takes way too much time doing something, eating up 100% CPU. At this point, I hit the 'Break' button and try to find what's running that's taking so long. The problem is, this app has a hefty amount of threads runnin...

Multiple Inheritance in Python (Problem Specific)

Can anyone here identify why the TypeError is being raised at the bottom of this example shown below? >>> import threading >>> class SessionManager(threading.Thread, threading._RLock, dict): UPDATE = 60 * 60 def run(self): while True: time.sleep(self.UPDATE) with self: for key in...

read and write thread using a single tcp socket

Hi, I'm using a C socket library I found online to implement a tcp socket data transfer program. Is it possible to make 2 threads share the same socket connection (1 read and 1 write), and have the read thread perform a blocking read and recv data while the write thread constantly writes data? All of the example socket programs I've se...

Is BackgroundWorker a good subsititute for AsyncOperationManager?

Here's what I'm trying to solve: My class (which could be hosted by an UI app or a windows service or whatever), needs to receive windows messages. Somewhere around here, someone gave the suggestion (and some source code) to create a windows form in a separate thread that will create the form and whenever a windows message that I'm inte...

Is This a Good Design for Creating Thread-Safe Classes in C#?

Often, when I want a class which is thread-safe, I do something like the following: public class ThreadSafeClass { private readonly object theLock = new object(); private double propertyA; public double PropertyA { get { lock (theLock) { return propertyA; ...

Creating an INotifyPropertyChanged proxy to dispatch calls to UI thread

I would like to create a dynamic proxy for binding WinForms controls to objects changed by a different (non-GUI) thread. Such a proxy would intercept the PropertyChanged event and dispatch it using the proper SynchronizationContext. That way I could use a helper class to do the job, without having to implement the synchronization manual...

Detect the bounds of the stack of the current thread

Hello, I'm writing a semi-accurate garbage collector, and I'm wondering if there is a way to accurately detect the boundaries of the system-allocated stack for a given thread. I need this so I can scan the stack for roots (pointers), and my current approach is to save the stack pointer when entering a new thread and when entering main()...

Design options for references into a thread safe cache when evicting older entries

I'm trying to design a simple cache that follows the following rules: Entries have a unique key When the number of entries in the cache exceeds a certain limit, the older items are evicted (to keep the cache from getting too large). Each entry's data is immutable until the entry is removed from the cache. A 'reader' can access an entry...

Progress "bar" using threads in vb.net

I currently have a program that runs several "intense" queries. I added a textbox and presented status updates when a query was starting, eding and how many were left. This would suite my need, but the textbox doesn't actually display anything until all the queries are finished. It then displays all the updates at once. I'm assuming upda...

How do I pass transactions between threads for parallel execution?

I'd like to execute a task in parallel where each thread needs to have DB access but if one thread fails the transactions in all threads will fail. You can assume that the transaction is active before the threads are created and that it's committed after they complete. I'm also using a TransactionScope under the System.Transactions nam...

WPF: When do I need to call Dispatcher.BeginInvoke

I know that Dispatcher.BeginInvoke is needed whenever I'm updating the GUI on a background thread. But how do I determine at runtime if it is needed? ...

VTK window thread from main thread, C++

hello, I am just learning VTK (and C++ GUI programming) and have hopefully simple question. The main application launches rendered window at some point in application. Would like to be able for the main thread to continue, while VTK window is displayed. Is there a particular method to launch VTK window as a thread? My environment is L...

Python Process blocked by urllib2

I set up a process that read a queue for incoming urls to download but when urllib2 open a connection the system hangs. import urllib2, multiprocessing from threading import Thread from Queue import Queue from multiprocessing import Queue as ProcessQueue, Process def download(url): """Download a page from an url. url [str]: url...

How do I communicate between multiple threads?

I'm writing a plug-in for another program which uses the native program to open a series of files to extract some data from. One problem I am having is the process takes a long time and I want to keep the user interface from hanging. Plus I also want to give the user the ability to cancel the process before it completes. In the past I've...

WPF: Where do I get a Threadsafe CollectionView?

When updating a collection of business objects on a background thread I get this error message: This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread. Ok, that makes sense. But it also begs the question, what version of CollectionView does support multiple th...

Core Data multi thread application

Hi all, I'm trying to use core data in a multi thread way. I simply want to show the application with the previously downloaded data while downloading new data in background. This should let the user access the application during update process. I have a NSURLConnection which download the file asyncronously using delegate (and showing...

Best Way to wake a thread up to quit? C#

I spawn a thread (only one) to do some work and it pretty much takes care of itself not accessing any data outside of the tread except calling callback() to see if the user wants to quit (also sends a status report back to the main thread to display in the GUI). When the close closes the exe i would like to wake up the thread and have i...

How to paint contents in multi-thread using qt?

Hi All, I want to paint contents in a multi-thread application using qt. The qt runs in the main thread. I have a thread B to generate paint tasks and to send tasks to qt main thread. Currently, I call "mywidget.update" in thread B, the "mywidget.paintEvent(..)" will be triggered in main thread. My problem is that I cannot pass any o...

Mutex not being respected in synchronized methods in Java class

I'm running into mutex issues with my Queue class under load which I'm at a loss to figure out why they are happening. objects = new ArrayList<Object>(); public synchronized int getSize(){ return objects.size(); } public synchronized Object dequeue(){ if(getSize()==0){ try { wait(); } catch (InterruptedException e) { // TOD...

Windows and Linux thread priority equivalence

Windows OS defines the following constants as thread priority: THREAD_PRIORITY_IDLE (-15) THREAD_PRIORITY_LOWEST (-2) THREAD_PRIORITY_BELOW_NORMAL (-1) THREAD_PRIORITY_NORMAL (0) THREAD_PRIORITY_ABOVE_NORMAL (1) THREAD_PRIORITY_HIGHEST (2) THREAD_PRIORITY_TIME_CRITICAL (15) And Linux has sched_get_priority_max() and sched_get_priorit...