multithreading

Which .Net Timer() to use

I have a legacy WinForms Mdi App in VB.Net 2.0 which I am adding functionality to. One of the additions is a warning which needs to be raised when the current time nears a specified value (a deadline). My intention is to check the time once an hour until there is less than an hour until the deadline, then display warnings at specified in...

Application window sent behind other windows on closing different thread (C#)

I'm writing a Windows Forms Application in C#.NET On startup, the application displays a splash screen which is running in a separate thread. Whilst the splash screen is showing, the main application is initialising. Once the main application has finished initialising, the main form of the application is displayed, and the splash scre...

[.NET] Use asynchronous delegates or ThreadPool.QueueUserWorkItem for massive parallelism?

I have a .NET application that processes around 300,000 records in a batch import, and it takes a few seconds per record so I would like to parallelize this. In the following code, what's the difference between ProcessWithAnsycDelegates() and ProcessWithThreadPool()? public class ResultNotification { public EventHandler event Success; ...

synchronizing io operation in java on a string method argument?

Basically, I have a class with 2 methods: one to serialize an object into an XML file and another to read an object from XML. Here is an example of synchronized part from the method that restores an object: public T restore(String from) throws Exception { // variables declaration synchronized (from) { try { de...

What is a basic example of "low-level" multi-threading in C++ ?

I'm a kinda newbie developer with a few years under my belt. Recently I interviewed at a game company and was asked "have you done any multi-threading?" I told them about having a C# app with a few Threads... and then I said a bit about transactions and locking etc in Sql. The interviewer politely told me that this was too high-level ...

Need a good tool to explore a process and threads

We have some problems at our production code, my main problem is that we have some process that growing too much, as I think connections that someone forget to close. or maybe a communication error that causes them to be orphans. I am looking for a good tool to explore those process (also threads). I already know the Process explorer, ...

What is the equivalent of Thread.SetApartmentState in C++?

In C# there is a method SetApartmentState in the class Thread. How do I do the same thing in C++? ...

COM: calling from other thread causes crashes, how to make it run on the same thread?

I am doing a BHO (extension for IE) that receives events on other thread. When I access the DOM from that other thread, IE crashes. Is it possible to make the DOM accessed from the same thread as the main BHO thread so that it does not crash? It seems like a general COM multithreading problem, which I don't understand much. ...

What tools exist for testing multithreaded .net code?

Are there any tools that can help find race conditions when testing multi-threaded .net code? I'm looking for something with similar capabilities to IBM's ConTest tool for Java. ...

What is the difference between a process and a thread

What is the technical difference between a process and a thread? I get the feeling a word like 'process' is over used and there is also hardware and software threads. How about light-weight processes in languages like Erlang? Is there a definitive reason to use one term over the other? ...

How to sync access to file between ASP.NET web site and ASP.NET web service on one web server

I have deployed ASP.NET web site and ASP.NET web service on the same web server. Both of them require access to shared file. How to implement/share lock that supports single writers and multiple readers? If somebody reads, nobody can write, but all still can read. If somebody writes, nobody can read/write. ...

How to join a thread that is hanging on blocking IO?

I have a thread running in the background that is reading events from an input device in a blocking fashion, now when I exit the application I want to clean up the thread properly, but I can't just run a pthread_join() because the thread would never exit due to the blocking IO. How do I properly solve that situation? Should I send a pth...

Are threads reused between requests in ASP.Net?

I'm just wondering if the same thread is used for each session, or if its dangerous to count on a particular thread between requests. What I'm getting at, is can I use thread static storage? ...

How to implement blocking read using POSIX threads

I would like to implement a producer/consumer scenario that obeys interfaces that are roughly: class Consumer { private: vector<char> read(size_t n) { // If the internal buffer has `n` elements, then dequeue them // Otherwise wait for more data and try again } public: void run() { read(10); re...

Is there an equivalent to Java's "kill -3" for a .NET CLR thread dump?

Hi, Java has the thread dump which is triggered by a signal 3 sent to the process (e.g. "kill -3 PID"). The equivalent I've found for .NET is to use ADPlus (http://support.microsoft.com/kb/286350). This basically attaches a debugger, takes a mini dump, and executes a few commands. I find .NET's approach to be a very brute force, cludgy a...

What is the best way to update form controls from a worker thread?

I've done some research and I can't really find a preferred way to do updating of form controls from a worker thread in C#. I know about the BackgroundWorker component, but what is the best way to do it without using the BackgroundWorker component? ...

Why does AbstractQueuedSynchronizer interrupt on acquring lock

I was looking at the source code of java.uti.concurrent.locks.AbstractQueuedSynchronizer and the acquire() method looks something like this - public final void acquire(int arg) { if (!tryAcquire(arg) && acquireQueued(addWaiter(Node.EXCLUSIVE), arg)) Thread.currentThread().interrupt(); } Why does it interrupt the t...

When should the Win32 InterlockedExchange function be used?

I came across the function InterlockedExchange and was wondering when I should use this function. In my opinion, setting a 32 Bit value on an x86 processor should always be atomic? In the case where I want to use the function, the new value does not depend on the old value (it is not an increment operation). Could you provide an example...

WaitForObject

can anyone please tell me what is the return value of WaitForObject() function . I do not mean the type of return value (int ) . What does it return if the event is signalled and what does it return if the event is not signalled . Thanks ...

How to get pointer from another thread?

Let's have the following class definition: CThread::CThread () { this->hThread = NULL; this->hThreadId = 0; this->hMainThread = ::GetCurrentThread (); this->hMainThreadId = ::GetCurrentThreadId (); this->Timeout = 2000; //milliseconds } CThread::~CThread () { //waiting for the thread to terminate if (...