multithreading

How to implement a message pump in Non-UI thread in .NET?

I am reading this blog: Use Threads Correctly, and I am wondering: How to implement a message (Note: I don't mean Windows Message here) pump in a non-UI thread? What I want is that the message can be an object or a command, say an Action<T>/Func<T>, etc. Do I have to use separate queue for different type of message? Say one queue for o...

Trace/BPT trap when running feedparser inside a Thread object

Hello, I am trying to run a Thread to parse a list of links using the universal feed parser, but when I start the thread I get a Trace/BPT trap. Here's the code I am using: class parseRssFiles(Thread): def __init__ (self,rssLinks): Thread.__init__(self) self.rssLinks = rssLinks def run(self): self.rssContents =...

Delphi - WndProc() in thread never called

I had code that worked fine when running in the context of the main VCL thread. This code allocated it's own WndProc() in order to handle SendMessage() calls. I am now trying to move it to a background thread because I am concerned that the SendMessage() traffic is affecting the main VCL thread adversely. So I created a worker thread ...

What are the tell-tale signs that my code needs to make use of multi-threading?

Hi, I am using a third party API which performs what I would assume are expensive operations in terms of time/resources used (image recognition, etc). What tell-tale signs are there that the code under test should be made to use threads to increase performance? I have a profiler and will be profiling the code I write which will rely on...

Is this a valid, lazy, thread-safe Singleton implementation for C#?

I implemented a Singleton pattern like this: public sealed class MyClass { ... public static MyClass Instance { get { return SingletonHolder.instance; } } ... static class SingletonHolder { public static MyClass instance = new MyClass (); } } From Googling around for C# Singleton implementat...

Which Qt classes use the disk directly?

I'm trying to write a library to separate all the disk activity out into its own thread, but the documentation doesn't really care about such things. What I want to accomplish is that aside from startup, all disk activity is asynchronous, and for that, I need to wrap every class that accesses the disk. Here's what I found so far: QtCor...

running multi threads in Java

My task is to simulate activity of couple of persons. Each of them has few activities to perform in some random time: fast (0-5s), medium(5-10s), slow(10-20s) and very slow(20-30s). Each person performs its task independently in the same time. At the beginning of new task I should print it's random time, start the task and then after tim...

Synchronized IEnumerator<T>

I'm putting together a custom SynchronizedCollection<T> class so that I can have a synchronized Observable collection for my WPF application. The synchronization is provided via a ReaderWriterLockSlim, which, for the most part, has been easy to apply. The case I'm having trouble with is how to provide thread-safe enumeration of the col...

Help needed with InvokeRequired for Web.UI

I have a multi-threaded application in C# which tries to write to a TextBox in a Windows.Forms created by another thread. As threads cannot modify what has not been created by them, I was using InvokeRequired as shown on the code below, to solve this problem. public delegate void MessageDelegate(Communication message); void agent_Mess...

C++ thread to separate process

Is there any way I can have a thread branch off into its own independent process? I know there's the CreateProcess function but as far as I can tell, you can only run external applications with it. Is what I'm asking for at all possible? ...

Multithreading WPF application, communication with service

Hello, I have WPF application which communicates with WCF service(service is Publisher and WPF application is Subscriber). I need multiple subscriptions to service from one application with callbacks to run in multiple threads. In each thread, application will subscribe to service and on callback(in same thread) save values to DB. Plea...

Is HttpModule shared among working threads?

Do I have to lock access to instance members? Example: public class HttpModule : IHttpModule { //... Dictionary<int, int> foo; void UseFoo(int a, int b) { foo[a] = b; } } ...

How to get number of cores in C?

I'm writing a program in C on windows that needs to run as many threads as available cores. But I dont know how to get the number of cores. Any ideas? ...

Some more multitasking java issues

I had a task to write simple game simulating two players picking up 1-3 matches one after another until the pile is gone. I managed to do it for computer choosing random value of matches but now I'd like to go further and allow humans to play the game. Here's what I already have : http://paste.pocoo.org/show/200660/ Class Player is a co...

Singleton again, but with multi-thread and Objective-C

I know Singleton pattern has been discussed so much. But because I'm not fully understand the memory management mechanism in Objective-C, so when I combined Singleton implementation with multithreading, I got a big error and cost me a whole day to resolve it. I had a singleton object, let's call it ObjectX. I declared an object inside O...

How to use pthread_atfork() and pthread_once() to reinitialize mutexes in child processes

We have a C++ shared library that uses ZeroC's Ice library for RPC and unless we shut down Ice's runtime, we've observed child processes hanging on random mutexes. The Ice runtime starts threads, has many internal mutexes and keeps open file descriptors to servers. Additionally, we have a few of mutexes of our own to protect our intern...

Threads and select mixing in ruby

Hello, The Ruby framework I am using provides a TcpServer class which, surprisingly, establishes a TcpServer. It has two threads - one monitors with Kernel.select the listener thread and dispatches a on_client_connect(fd) method and the other monitors established connections and dspatches on_client_data(fd). I want to use the TcpServer...

Multithreading and booleans

Hi Everyone, I have a class that contains a boolean field like this one: public class MyClass { private bool boolVal; public bool BoolVal { get { return boolVal; } set { boolVal = value; } } } The field can be read and written from many threads using the property. My question is if I should fence the g...

WPF scrollviewer - Access using multiple threads

I want to access a scrollviewer from another thread. Please tell me how to do detach it from the Main Thread so that I can change the Offsets of the scrollviewer. Thanks ...

How to indefinitely pause a thread in Java and later resume it?

Maybe this question has been asked many times before, but I never found a satisfying answer. The problem: I have to simulate a process scheduler, using the round robin strategy. I'm using threads to simulate processes and multiprogramming; everything works fine with the JVM managing the threads. But the thing is that now I want to have...