multithreading

Unhandled exceptions in BackgroundWorker

My WinForms app uses a number of BackgroundWorker objects to retrieve information from a database. I'm using BackgroundWorker because it allows the UI to remain unblocked during long-running database queries and it simplifies the threading model for me. I'm getting occasional DatabaseExceptions in some of these background threads, and I...

Set Identity of Thread

In C#, how do I set the Identity of a Thread? For example, if I have Thread MyThread, which is already started, can I change MyThread's IIdentity ? Or is this unpossible? ...

How does the Sun JVM map Java threads to Windows threads?

My application uses loads of Java threads. I am looking for a reliable understanding how the JVM (version 5 and 6) maps the Java threads to underlying Windows threads. I know there is a document for mapping to Solaris threads, but not Windows. Why doesn't Sun publish this information? I want to know if there's a 1:1 mapping, or if it v...

How do I safely populate with data and Refresh() a DataGridView in a multi-threaded application?

My app has a DataGridView object and a List of type MousePos. MousePos is a custom class that holds mouse X,Y coordinates (of type "Point") and a running count of this position. I have a thread (System.Timers.Timer) that raises an event once every second, checks the mouse position, adds and/or updates the count of the mouse position on t...

stopping a function executed on a winform button click

In a simple winform application, I call a function that endlessy create files on a button click event. I add Application.DoEvents() to the loop. I press the red X to close the form. the form closes, but files continue to be created ... I think its on the buttons thread, but shouldnt it be a background one ? trying changing Thread.Cur...

Changing DataGridViewRow Properties in Another Thread

Ok, so I'm binding a DataGridView to a BindingSource in a background thread while a little, "Please Wait" model window keeps the user entertained. No problem. However, I need to change some of the rows background colors based on the row's databounditem type. Like this: for (int i = 0; i < dgItemMaster.Rows.Count; i++) { if (dgItemM...

Do COM component invoked asynchronously from asp.net run on IO thread or worker thread??

I need to call a third party COM component from an asp.net site. The site is designed to run to pages asynchronously (marking the page and webpart as async). The page registers and invokes async calls by the standard page.RegisterAsyncTask() method. Async methods/components invoked on the managed components would be run on IO threads ...

What is meant by "thread-safe" code?

Does it mean that two threads can't change the undelying data simultaneously? or does it mean that the given code component will run with unpredictable results when more than one thread are running it? ...

When would you call java's thread.run() instead of thread.start()?

... the question says it all I believe! ...

C#: Waiting for all threads to complete

I'm running into a common pattern in the code that I'm writing, where I need to wait for all threads in a group to complete, with a timeout. The timeout is supposed to be the time required for all threads to complete, so simply doing thread.Join(timeout) for each thread won't work, since the possible timeout is then timeout * numThreads....

Cocoa 10.5 multithread app runs slowly

Got a Cocoa video capture app that works fine in 10.4. It uses NSThread to start the video capture driver. When app just started, video capture is very slow ( 1-2 fps). But after resize the UI window (or bring the window from background to foreground), video capture speed is back to normal. This only happens in 10.5. ...

Is SetEvent atomic?

Is it safe to have 2 or more threads call the Win32 API's SetEvent on the same event handler not being protected by a critical section? ...

Why the Global Interpreter Lock?

What is exactly the function of Python's Global Interpreter Lock? Do other languages that are compiled to bytecode employ a similar mechanism? ...

Do I need a semaphore when reading from a global structure?

A fairly basic question, but I don't see it asked anywhere. Let's say we have a global struct (in C) like so: struct foo { int written_frequently1; int read_only; int written_frequently2; }; It seems clear to me that if we have lots of threads reading and writing, we need a semaphore (or other lock) on the written_frequently me...

Why doesn't multithreading in c# reach 100% CPU?

I'm working on a program that processes many requests, none of them reaching more than 50% of CPU (currently I'm working on a dual core). So I created a thread for each request, the whole process is faster. Processing 9 requests, a single thread lasts 02min08s, while with 3 threads working simultaneously the time decreased to 01min37s, b...

Simple example of threading in C++

Can someone post a simple example of starting two (Object Oriented) threads in C++. I'm looking for actual C++ thread objects that I can extend run methods on (or something similar) as opposed to calling a C-style thread library. Thanks. Update - I left out any OS specific requests in the hopes that whoever replied would reply with c...

2008 MFC and threads?

I was reading this thread/post: http://stackoverflow.com/questions/262298/windows-c-ui-technology and am also wondering about a non .NET UI framework. Specifically - prior to .NET having support for serial ports (I can't believe they left that out of the first release of .NET) I was forced to use MFC for an application. I had not been...

C#, return statement in a lock procedure, inside or outside?

I just realized that in some place in my code I have the return statement inside the lock and sometime outside. Which one is the best? 1) void example() { lock (mutex) { //... } return myData; } 2) void example() { lock (mutex) { //... return myData; } } Which one should I use? ...

parameterizedThreadstart

What is the difference between parameterizedThreadstart, Threadstart and Thread? ...

Multithread read and write to a ::stl::vector, vector resource hard to release

I am writing code in VS2005 using its STL. I have one UI thread to read a vector, and a work thread to write to a vector. I use ::boost::shared_ptr as vector element. vector<shared_ptr<Class>> vec; but I find, if I manipulate the vec in both thread in the same time(I can guarantee they do not visit the same area, UI Thread always read...