multithreading

Heap corruption under Win32; how to locate?

I'm working on a multithreaded C++ application that is corrupting the heap. The usual tools to locate this corruption seem to be inapplicable. Old builds (18 months old) of the source code exhibit the same behaviour as the most recent release, so this has been around for a long time and just wasn't noticed; on the downside, source delt...

What are some good resources for learning threaded programming?

With the rise of multicore CPUs on the desktop, multithreading skills will become a valuable asset for programmers. Can you recommend some good resources (books, tutorials, websites, etc.) for a programmer who is looking to learn about threaded programming?...

How do I make event callbacks into my win forms thread safe?

When you subscribe to an event on an object from within a form, you are essentially handing over control of your callback method to the event source. You have no idea whether that event source will choose to trigger the event on a different thread. The problem is that when the callback is invoked, you cannot assume that you can make upd...

Scaling multithreaded applications on multicored machines

I'm working on a project were we need more performance. Over time we've continued to evolve the design to work more in parallel(both threaded and distributed). Then latest step has been to move part of it onto a new machine with 16 cores. I'm finding that we need to rethink how we do things to scale to that many cores in a shared memory ...

Compact Framework - how to wait for thread complete before continuing?

I have some code for starting a thread on the .NET CF 2.0: ThreadStart tStart = new ThreadStart(MyMethod); Thread t = new Thread(tStart); t.Start(); If I call this inside a loop the items complete out of order. How do introduce a wait after t.Start(), so that the work on the thread completes before the code continues? Will BeginInvoke/...

Thread safe lazy contruction of a singleton in C++

Is there a way to implement a singleton object in C++ that is: Lazily constructed in a thread safe manner (two threads might simultaneously be the first user of the singleton - it should still only be constructed once). Doesn't rely on static variables being constructed beforehand (so the singleton object is itself safe to use during t...

Has anybody used Google Performance Tools?

Looking for feedback on : http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools...

Multicore Text File Parsing

I have a quad core machine and would like to write some code to parse a text file that takes advantage of all four cores. The text file basically contains one record per line. Multithreading isn't my forte so I'm wondering if anyone could give me some patterns that I might be able to use to parse the file in an optimal manner. My first t...

Is the C# static constructor thread safe?

In other words, is this Singleton implementation thread safe: public class Singleton { private static Singleton instance; private Singleton() { } static Singleton() { instance = new Singleton(); } public static Singleton Instance { get { return instance; } } } ...

is there a "try to lock, skip if timed out" operation in C# ?

I need to try to lock on an object, and if its already locked just continue (after time out, or without it). the C# lock statement is blocking. ...

How to obtain good concurrent read performance from disk.

I'd like to ask a question then follow it up with my own answer, but also see what answers other people have. We have two large files which we'd like to read from two separate threads concurrently. One thread will sequentially read fileA while the other thread will sequentially read fileB. There is no locking or communication between ...

Is accessing a variable in C# an atomic operation?

I've been raised to believe that if multiple threads can access a variable, then all reads from and writes to that variable must be protected by synchronization code, such as a "lock" statement, because the processor might switch to another thread halfway through a write. However, I was looking through System.Web.Security.Membership usi...

Analyzing Multithreaded Programs

We have a codebase that is several years old, and all the original developers are long gone. It uses many, many threads, but with no apparent design or common architectural principles. Every developer had his own style of multithreaded programming, so some threads communicate with one another using queues, some lock data with mutexes, ...

Compact Framework/Threading - MessageBox displays over other controls after option is chosen

I'm working on an app that grabs and installs a bunch of updates off an an external server, and need some help with threading. The user follows this process: Clicks button Method checks for updates, count is returned. If greater than 0, then ask the user if they want to install using MessageBox.Show(). If yes, it runs through a loop an...

Multithreading Design Question

Consider this problem: I have a program which should fetch (let's say) a 100 records from the database, and then for each one it needs to get updated information from a web service. There are two ways to introduce parallelism in this scenario: I start of each request to the web service on a new Thread. The number of simultaneous thread...

When should I not use the ThreadPool in .Net?

When should I not use the ThreadPool in .Net? it looks like the best option is to use a ThreadPool. In which case, why is it not the only option. What are your experiences around this? ...

In WinForms, why can't you update UI controls from other threads?

I'm sure there is a good (or at least decent) reason for this. What is it? ...

Windows Forms Threading and Events - ListBox updates promptly but progressbar experiences huge delay

Our team is creating a new recruitment workflow system to replace an old one. I have been tasked with migrating the old data into the new schema. I have decided to do this by creating a small Windows Forms project as the schema are radically different and straight TSQL scripts are not an adequate solution. The main sealed class 'ImportC...

How should I unit test threaded code?

Hot-on-the-heels of of my previous unit testing related question, here's another toughie: I have thus far avoided the nightmare that is testing multi-threaded code since it just seems like too much of a minefield. I'd like to ask how people have gone about testing code that relies on threads for successful execution, or just how people...

Why is my asp.net application throwing ThreadAbortException?

self explanatory question. Why does this thing bubble into my try catch's even when nothing is wrong? Why is it showing up in my log, hundreds of times? I know its a newb question, but if this site is gonna get search ranking and draw in newbs we have to ask them ...