multithreading

Singleton dead reference problem

Hi, I was reading around a lot about singleton. I am thinking about the dead reference problem between singletons. In every primer on net , this problem is encountered when one singleton calls other singleton in its destructor, and that singleton is already destroyed, say Log singleton can be called from destructor of many other singlet...

How to avoid thread preemption in C++, VisualStudio(Windows)

Hi All, I developed a logger for testing our modules in c++, Win32 console, visual studio(Windows) Logger is running in one thread. While it displays output in console window, thread is getting preempted. Some other module thread is running. So output of other modules is getting mixed with output of Logger module in Console win...

Global variables not destructed in main thread?

I have a mixed-mode executable and I noticed that the constructor of my native global variables is called in the main thread, but the destructor is called in some other thread. The name of thread is 'Thread::intermediateThreadProc'. The global variables are What is the reason for this? And what is this 'Thread::intermediateThreadProc'...

Can I pass STL data structures to a Win32 message loop?

I have a multithreaded Windows application where one of the threads has a message pump in it. I need to send a message to that thread, passing information to it. However, one of the libraries I want to use in the worker thread requires std::string. Can I do something like the following: typedef struct tagCOMMAND { std::map<std::stri...

Want to put time gap between two events in Android application

Hello friends, I want put delay between two flips of the same image on ImageView. i.e. (1). Image loads with Animation (2). Wait for 1 or 1.5 seconds (3). Image changes with animation on the same ImageView. I tried to set Thread.Sleep() , didn't work. And yes, these all things I want to be done on android. ...

.NET: How to ensure that Thread 1 can see what Thread 2 has written in a field?

Environment: .NET 3.5 SP1. I've got two threads: UI thread and a background worker thread. The background worker thread periodically updates some fields in a shared object and the UI thread checks them. Nothing spectacular - just the progress, return values and thrown exceptions. Also the worker thread raises some events on the UI threa...

Conditional Variable vs Semaphore

When should one use a semaphore and when should one use a conditional variable (CondVar) ? ...

Waiting for all threads spawned by my code under test in JUnit test case

How do I ensure in a JUnit test case, that all the the threads spawned directly/indirectly by the method under test are done with there job, so that I can assert the final result? @Test public void testMethod() { Result result=method();// may spawn multiple threads to set result.value Assert.assertTrue(result.getValue()==4); //shoul...

Multithreading problem(UI not updated)

Hey, I have a problem in Multithreading. To describe this, I have two threads. On main thread I have some logic And on another thread, I have a logic and some logic to UI which will update UI. What I want to do is that I want to call some method after the UI on another thread is updated. I think I am supposed to use NSOperationQueue or s...

WPF: InotifyPropertyChanged, IValueConverter, & background threads

let's say we are using IValueConverter to format a GridView cell background color depending on its value. now let's say that value is calculated on a separate thread, after adding the item to the collection. var args = GetInput(); if (ValidateArgs(args)) { if (args.Rate.HasValue) Thre...

Twisted: deferred that fires repeatedly?

Deferreds are a great way to do asynchronous processing in Twisted. However, they, like the name implies, are for deferred computations, which only run and terminate once, firing the callbacks once. What if I have a repeated computation, like a button being clicked? Is there any Deferred-like object that can fire repeatedly, calling all ...

What are the dangers of starting a thread in the Application Start in global.asax? (asp.net)

If you start a thread in the Application Start of an asp.net site, what will happen when Application Stop is triggered? Also, the thread I'm starting will run forever. For instance if there are no active sessions for a while, the application is stopped. ...

How would you use msmq acknowledgements in an asp.net application?

What are best practices for using msmq acknowledgements in an asp.net application? In my case, some request from Flex to Asp.net (using WebORB or FluorineFX) adds an id to a queue. A windows service handles the queue to do a job with each id. Now, after I added the id to the queue, I can't just wait until a message arrives in the ackno...

Thread related issues and debugging them

Hi, This is my follow up to the previous post on memory management issues. The following are the issues I know. 1)data races (atomicity violations and data corruption) 2)ordering problems 3)misusing of locks leading to dead locks 4)heisenbugs Any other issues with multi threading ? How to solve them ? ...

Parallel Programming With Recursive Functions?

Background of the Problem: I'm trying to write a puzzle solution algorithm that takes advantage of multi-core processors and parallel processing. However, the ideal/easiest solution is a simple recursive function. What's the best way to break down the solution to both take advantage of parallel processing AND the recursive function?...

"Method is not supported" error when trying to invoke a delegate

I have a function Run(string, string[]) which I want to run on a separate thread, so I am using a delegate and BeginInvoke: private Func<string, string[], Stack<StackItem>> runner; public MainPage() { runner = Run; } private void btnStep_Click(object sender, RoutedEventArgs e) { // snip runner.BeginInvoke(tbCode.Text, GetA...

Problem using multithreading with simple WPF app

I am totally new to WPF, I have created a simple WPF app that lists whole drive structure (folder, files) to a TreeView, since this process takes a while I tried to use a thread to run the GetFolderTree() method and prevent the UI from becoming unresponsive, however I am facing some problems, I have created a Class named FolderBrowser wh...

Why does NextValue call of performanceCounter change thread affinity mask

Hi. I have a C# project, where I have to both access the current workload of my processor, and ensure, that I run some specific code on every kernel of the processor. My problem is, that accessing the workload of my processor seems to prevent me from correctly assigning a thread affinity mask. I have some code here, that illustrates the...

C# socket read error

In my program i'm creating socket and whes client connects i'm creating new thread and trying to read and write from/to connected to this socket, but alway get an Read Error because host-computer closed connection for the second command, first command from client worfs fine, and third works fine. i try to check if clientSocket is connect...

Why do thread creation methods take an argument?

All thread create methods like pthread_create() or CreateThread() in Windows expect the caller to provide a pointer to the arg for the thread. Isn't this inherently unsafe? This can work 'safely' only if the arg is in the heap, and then again creating a heap variable adds to the overhead of cleaning the allocated memory up. If a stack...