multithreading

Why is Thread.Join not letting through COM messages?

I am running some multi-threaded code that does the following. On an STA thread, I create a 'worker' thread, and run it. The STA thread then waits for the worker thread to exit. The worker thread calls a method on a proxy to an STA COM object on the STA thread, and then exits. In step 2, I'm using Thread.Join() to wait for the worke...

Application.Exit() vs Application.ExitThread() vs Environment.Exit()

I am trying to figure out which I should be using. On closing my WinForm App fires of a Form in Dialog mode. That form runs a Background worker that Syncs the DB with the remote DB and displays it's progress on the "Splash Form." I have a method like so --> private void CloseMyApp() { SaveUserSettings(); ...

In WPF MVVM, how to spawn a background task that runs a callback on the UI Thread?

I'm familiar with the control's dispatcher object but that doesn't solve my issue in an MVVM scenario. I've got a UI command, that calls a method on my VM, that spawns a thread and then returns, when the thread is done (background worker might be good for this?) it will raise a callback, but the trick is, that callback modifies an obser...

What is a multithreaded application?

I am looking to learn more about threading and I wanted to know: what is a multithreaded application? ...

boost:thread crashes microsoft C++ compiler

Brief version of my question: This code crashes the compiler. pThread[0] = new boost::thread( boost::bind( &cGridAnimator::DoJob, // member function this ), // instance of class 0 ); // job number The compiler crashes when attempting to compile this code. ( It is not my program that...

ASP.NET 2.0 web site gets ThreadAbortException

We're running a web service as a web site project. Clients make requests which return after a few seconds, but which spawn a thread that should run for hours. The thread makes web requests and writes to a database, and is throttled with Thread.Sleep calls. After running for about 20 minutes with several threads running, all the thread...

Thread.join not behaving as I expected in scala

In the code below I create 20 threads, have them each print out a message, sleep, and print another message. I start the threads in my main thread and then join all of the threads as well. I would expect the "all done" message to only be printed after all of the threads have finished. Yet "all done" gets printed before all the threads...

WPF updating the UI with a certain delay

Hi, I have a slideshow application where i want to wait a certain amount of seconds, then show my front page, then wait again, then show next page, and so on. My problem is that when i use Thread.Sleep in between, the UI arent updated, it just sits there waiting and i only see my last control (after the full amount of time has passed (i....

Returning a value from thread?

How to Return a value from a thread? in .NET ...

How is access to the UI thread handled in C#?

How is access to the UI thread handled in C#? why is the UI thread treated differently from other threads? thank you guys for your help really appreciate it ! ...

Cocoa Core Data - Background Thread

I have a core data application based on the default xcode template, I have the main UI which is used for viewing the data and then I have a background thread which is downloading/inserting/editing data. I figured when the application launches I can create two NSManagedObjectContext, one which the applications reads from and the other in...

Win32: ReadFileEx() on STD_IN_HANDLE blocks, why?

Hi all, I'm trying to use the Win32 API to make a sub-thread that reads from STD_INPUT_HANDLE and pushes the bytes it reads into a socket. Because I want to be able to shut down this thread safely when it's time to exit, I'm using ReadFileEx() and overlapped I/O instead of plain old blocking ReadFile(). The idea is that my thread will...

C# Threading: a race condition example

I am reading http://www.mono-project.com/ThreadsBeginnersGuide. The first example looks like this: public class FirstUnsyncThreads { private int i = 0; public static void Main (string[] args) { FirstUnsyncThreads myThreads = new FirstUnsyncThreads (); } public FirstUnsyncThreads () { // Creating our two threads. The ThreadSta...

Is there potential starvation in this code or is it just me?

I am trying to learn Scala and find it a great language so far. I learn from "Beginning Scala" by David Pollak. In chapter 3 there is this piece of code, which illustrates how to write multi-threaded code without synchronized blocks (this code is copied from the book, it's available for download from Apress site, I don't mean to break an...

rand() doesn't obey srand() in Qt Creator

I've written a program in Qt Creator 1.0.0 (Qt version 4.5.0) where at the beginning of main() function I've put srand(time(0)); Then I'm calling rand() from another thread (subclass of QThread). In that function, rand() is producing same sequence of numbers each time I'm running the program. Why is this happening? Thanks in advanced...

Threads using visual stdio2008

I want to implement threading in c++.I am using visual stdio2008 and wish to implement threading using pthreads.can any one guide me about pthreads and also about there implementations in vs2008.Thanking in anticipation ...

"Safe handle has been closed" with SerialPort and a thread in C#

Good afternoon everybody! I have this threaded SerialPort wrapper that reads in a line from the serial port. Here is my thread's code. protected void ReadData() { SerialPort serialPort = null; try { serialPort = SetupSerialPort(_serialPortSettings); serialPort.Open(); string data; whi...

Using ThreadLocal with existing classes which contain static members

I'm trying to use ThreadLocal to provide thread safety to pre-existing non-thread-safe classes, but experiencing problems. It appears that there is no isolation being performed - that the threads still share the static, instead of it being local to each thread. I believe my usage is almost exactly parallel with the example localization...

how to use lock on a IList

Hi everyone, I have a static collections which implements IList interface. This collection is used throughout the application, including adding/removing items. Due to multithread issue, I wonder what I can do to ensure that the list is modifying one at a time, such as when 1 thread try to add an item, another thread should not do delet...

Throw a NullReferenceException while calling the set_item method of a Dictionary object in a multi-threding scenario

Our website has a configuration page such as "config.aspx", when the page initializing will load some infomations from a configuration file. To cache the loaded informations we provided a factory class and we call a public method of the factory to get the configuration instance when the page loaded. But sometimes when the Applciation Poo...