multithreading

C# Events between threads executed in their own thread (How to) ?

Hello, I'd like to have two Threads. Let's call them : Thread A Thread B Thread A fires an event and thread B listen to this event. When the Thread B Event Listener is executed, it's executed with the Thread A's thread ID, so i guess it is executed within the Thread A. What I'd like to do is be able to fire event to Thread B sayin...

How do I get the Threads window in VisualStudio2008?

How do you get this window in VisualStudio 2008: I am especially looking at the "View" menu. It's just not there. I have a non-Express version of VisualStudio 2008. I found the above screenshot via google..that's the window I need. Any way to make that window open? ...

Blackberry stopwatch implementation

I'm trying to write a blackberry app that is basically a stopwatch, and displays lap times. First, I'm not sure I'm implementing the stopwatch functionality in the most optimal way. I have a LabelField (_myLabel) that displays the 'clock' - starting at 00:00. Then you hit the start button and every second the _myLabel field gets updated ...

Thread Sleep and Windows Services

I'm working on a Windows Service that's having some issues with Thread.Sleep() so I figured I would try to use a timer instead as this question recommends: http://stackoverflow.com/questions/998142/using-thread-sleep-in-a-windows-service Thing is it's not entirely clear to me how one might implement this. I believe this is the way but ...

Tinyxml Multi Task

I have a single xml file and every new thread of the program (BHO) is using the same Tinyxml file. every time a new window is open in the program, it runs this code: const char * xmlFileName = "C:\\browsarityXml.xml"; TiXmlDocument doc(xmlFileName); doc.LoadFile(); //some new lines in the xml.. and than save: doc.SaveFile(xmlFileName);...

Running another process without GUI freezing

I'm having trouble getting my GUI to appear and not freeze while running (and waiting for) an outside process. In this case, drivers.exe is a very simply program where the user simply clicks "OK". So whenever I click OK, it exits. I am trying to simply make my status strip count numbers up (really fast) as drivers.exe is executing. B...

How to learn about Threads, Especially in Java.

I have always been kind of confused by threads, and my class right now makes heavy use of them. We are using java.util.concurrent but I don't even really get the basics. UpDownLatch, Futures, Executors; these words just fly over my head. Can you guys suggest any resources to help learn what I need from the ground up? Thanks a lot in adv...

Is Stream.Write thread-safe?

I'm working on a client/server library for a legacy RPC implementation and was running into issues where the client would sometimes hang when waiting to a receive a response message to an RPC request message. It turns out the real problem was in my message framing code (I wasn't handling message boundaries correctly when reading data off...

Multi-Threading in .NET

Hi all.. I wrote this program, that is supposed to read about 5000 email address and send an pre-defined html mail. I am using the background worker component. The problem is this: I have wired up the method who is supposed to send the mail. But I am calling another method that is supposed to append the body html to the salutation, like...

Using lock(obj) inside a recursive call

As per my understanding a lock is not released until the runtime completes the code block of the lock(obj) ( because when the block completes it calls Monitor.Exit(obj). With this understanding i am not able to understand the reason behind the behaviour of the following code. private static string obj = ""; private static void ...

How to test if a thread is holding a lock on an object in C#?

Hi, Is there a way to test if the current thread is holding a monitor lock on an object? I.e. an equivalent to the Thread.holdsLock in Java. Thanks, ...

Processes Allocation in .Net

I'm writing some program which should perform calculations concurrently according to inputs which reach the system all the time. I'm considering 2 approaches to allocate "calculation" processes: Allocating processes in the system initialization, insert the ids to Processes table, and each time I want to perform calculation, I will chec...

How can I tell if waiting on Event has timed out?

Hello. >>> import threading >>> event = threading.Event() >>> event.set() >>> print event.wait(1) None >>> event.clear() >>> print event.wait(1) None So it basically returns None both when condition was True and False. How can I distinguish the case of timeouting from the one with no waiting at all? Meanwile, the docs say This met...

check that every thread of semaphore has completed

I have a Semaphore that runs trough a list of Job objects. Here is a sample of the code: List<Job> jobList = jobQueue.GetJobsWithStatus(status); if (jobList.Count > 0) { foreach (Job job in jobList) { semaphore.WaitOne(); // Only N threads can get here at once job.semaphore = semaphore; ThreadStart threadStart = ne...

A signalling thread problem

Hello - I am attempting to get a thread running which will be responsible for detecting a signal from any other thread within the same process. sigset_t sigset; sigfillset(&sigset); pthread_sigmask( SIG_BLOCK, &sigset, &old ); Once i've done this, I then daemonize the process: m_child = fork(); if (m_child == 0) { // Start t...

[C#] Reading input from secondary thread

Hi! I have an XNA application, and I need to redirect the input queue into a custom thread, instead of having it available only in the main thread. Is there an alternative to AttachThreadInput? ...

Unsynchronized getter/setter behavior in Java

I have a class that serves as a delegate to another. public class Delegate { private AnotherClass ac; public void delegateCall() { this.ac.actualCall(); } public void setAC(AnotherClass ac) { this.ac = ac; } } What are the ramifications if I have lots of threads calling delegateCall() and another...

TCP, HTTP and the Multi-Threading Sweet Spot

I'm trying to understand the performance numbers I'm getting and how to determine the optimal number of threads. See the bottom of this post for my results I wrote an experimental multi-threaded web client in perl which downloads a page, grabs the source for each image tag and downloads the image - discarding the data. It uses a non...

Log4Net performance

I have written a C# app that runs constantly in a loop and several threads write to a log4net file. The issue is that the longer the app is running, the more time it takes to complete a loop. I have run a ANTS Performance profiler, and noticed that most of this CPU time is spent logging with log4.net. The more verbose the logs the mor...

Proving the following code not thread safe

Hi, How can I quickly prove that the following class is not thread-safe (as it uses Lazy Initialization and not using synchronization) by writing some code ? In other words, if I am testing the following class for thread safety, how can I fail it? public class LazyInitRace { private ExpensiveObject instance = null; public Expensi...