multithreading

What is the preferred method of marshalling COM interfaces across threads?

What are the pros/cons of using the GIT as opposed to CoMarshalInterThreadInterfaceInStream and CoGetInterfaceAndReleaseStream for marshalling COM interfaces across threads? Are there strong reasons for preferring one method over the other, or is it more a matter of personal preference? ...

Java Thread problem

I want to stop threads by using a boolean field. I have implemented some code to do this which is as follows: My thread class is like this: public class ParserThread implements Runnable { private volatile boolean stopped = false; public void stopTheThread() { stopped = true; } : : } And below is the main ...

Multi-threaded application interaction with logger thread

Hi there, folks. Here I am again with questions about multi-threading and an exercise of my Concurrent Programming class. I have a multi-threaded server - implemented using .NET Asynchronous Programming Model - with GET (download) and PUT (upload) file services. This part is done and tested. It happens that the statement of the proble...

WPF: How to stop the PriorityBinding's thread.

Listbox's ItemsSource is TList in XImage's Dispose method, How do I stop the thread which load the thumbnail? <ListBox.ItemTemplate> <DataTemplate> ... <Image.Source> <PriorityBinding> <Binding Path="Thumbnail" I...

What is the purpose of Dispatcher CheckAccess?

On Async webservice on complete event, there is a code like belows. Debug.Assert(Dispatcher.CheckAccess()); // don't do marshaling here- it's already runinng on UI thread! Does anybody know what happens if I remove this code? or able answer my questions? ...

Do sequence points prevent code reordering across critical section boundaries?

Suppose that one has some lock based code like the following where mutexes are used to guard against inappropriate concurrent read and write mutex.get() ; // get a lock. T localVar = pSharedMem->v ; // read something pSharedMem->w = blah ; // write something. pSharedMem->z++ ; // read and write something. mutex.release() ; // rel...

Atomic Instructions and Variable Update visibility

On most common platforms (the most important being x86; I understand that some platforms have extremely difficult memory models that provide almost no guarantees useful for multithreading, but I don't care about rare counter-examples), is the following code safe? Thread 1: someVariable = doStuff(); atomicSet(stuffDoneFlag, 1); Thread...

Is there a way to force Core Animation to run it's thread?

Core Animation uses a background thread to do it's job. Now the problem is this: I have a heavy calculation going on in the main thread. Core Animation immediately freezes until that calculation is done. And then it continues to finish it's animations. I remember reading in a document that CA has a low priority in processing time, meanin...

Multi Threading locks and monitor class not working

I have a file that is read and written to. I need to make sure when its been written to, nobody else will try to write to it. I put a lock on the whole function which allows to either read or write but I still get errors such as The process cannot access the file 'FILENAME' because it is being used by another process. public static TY...

How to create a Run Loop which is kicked only by performSelector... method calls?

Hey guys! I'm messing around with threads a little bit. Now consider this: I have a main thread. I start a new thread. In it's entry-point method, I want to make a run loop. Now the documentation tells meh that I have to have a input source. Otherwise my run loop exits immediately. bad. okay. but I have no other input source than my perf...

does presence of mutex helps getting rid of volatile key word ?

Hi , I have a multi-R/W lock class that keeps the read, write and pending read , pending write counters. A mutex guards them from multiple threads. My question is Do we still need the counters to be declared as volatile so that the compiler won't screw it up while doing the optimization. Or does the compiler takes into account that t...

Most efficient way to use HttpListener to serve requests in a multithreaded fashion

Scenario: I have 50 (or more) processes running (myproc.exe) that do some business logic. I want to have a web server that takes simple GET's (/foo.html) and just pass this information (the location of GET) one of the running myproc.exe myproc.exe's and this exe (the webserver) have named pipes between them (so 50 named pipes) that pas...

Getting thread id of current method call

Is there a way to print out the current thread id on which the current method is executing on? (objective-c please) ...

How to stop a background thread on keyboard flip in android

How can I stop a background thread on keyboard flip in android? ...

Setting priority to java's threads

I have a program that runs in a few threads. The main thread shares an object with the other threads and in the main I have a call to: synchronized(obj){ do stuff } I have a suspicion that the main thread is starved and isn't getting access to obj. How do I raise the priority of the main thread or is it already higher than the oth...

Why doesn't GeckoFX Navigate() request work if launched in a seperate thread?

Why does this work, private void buttonBoo_Click(object sender, EventArgs e) { GeckoBrowser.Navigate("http://www.google.com/"); } and this not? private void buttonBoo_Click(object sender, EventArgs e) { Thread thread = new Thread(delegate() { GeckoBrowser.Navigate("http://www.google.com/"); }); thread.Start(); } ...

Difference between BackgroundWorker and System.Threading.Thread

What is the difference between creating a thead using BackgroundWorker and creating a thread using System.Threading.Thread? ...

Testing a background worker with rhino mocks

lets say i have a background worker in a class that perform db query in a background thread. i wanna test this class so i mock my db and return some collection so far so good, make sure my background worker called the do work and than i wanna make sure that the finish also happened. I've noticed that the test pass and fail randomly (...

Catching WM_GETMINMAXINFO from notepad.exe doesn't work

Hello! I want to catch all WM_GETMINMAXINFO messages which are sent to the "nodepad.exe" application. My base app is written in C#, the DLL with the windows hook is written in C. Let me show you the hook inside the C DLL: file: dll.h #ifndef _DLL_H_ #define _DLL_H_ #include <windows.h> #if BUILDING_DLL # define DLLIMPORT __declspec...

Invoking UI delegate causes UI to be hidden...

Hi, Suppose I have thread 1, the main window UI thread and thread 2, a login UI thread that is modal form. Now thread 1 executes a piece of code and wants to change a UI element in the login form so it invokes a delegate to change something in thread 2. But when it does so, the login form becomes hidden behind the main window and there...