multithreading

[WPF] The calling thread cannot access this object because a different thread owns it.

Why I can't create CroppedBitmap in the following code ? I got an exception : The calling thread cannot access this object because a different thread owns it. If I change the code to CroppedBitmap cb = new CroppedBitmap(new WriteableBitmap(bf), new Int32Rect(1, 1, 5, 5)); the exception is gone? why ? Code 1: exception at cb.Freeze()...

C++ Thread Safe Integer

Hello everyone, I have currently created a C++ class for a thread safe integer which simply stores an integer privately and has public get a set functions which use a boost::mutex to ensure that only one change at a time can be applied to the integer. Is this the most efficient way to do it, I have been informed that mutexes are quite ...

C# can I lock a method parameter?

We have a class variable ArrayList binaryScanData in a class. In all methods having access to it, we put lock(binaryScanData) on it because it is shared. Now we want to move one of those methods out to another util class to make it a static method. We will pass that binaryScanData into the method like this: public static void convertAnd...

Running processes at different times stops events from working - C

Hello, This is a question which follows on from my previously answered question here At first I assumed I had a problem with the way I was creating my events due to the handles for OpenEvent returning NULL, I have managed to find the real cause however I am not sure how to go about it. Basically I use Visual Studio to launch both Proc...

Why a thread is aborted in ASP.NET MVC (again)?

Here is what I do in a controller action: create and start a new Thread that does a relatively long processing task (~30 seconds on average, but might be several minutes) immediately return the page response so the user knows processing has started (trivially, a Json with a task ID for polling purposes). At some random point, ThreadA...

Multiple Producers Single Consumer Queue

I am new to multithreading and have designed a program that receives data from two microcontroller measuring various temperatures (Ambient and Water) and draws the data to the screen. Right now the program is singly threaded and its performance SUCKS A BIG ONE. I get basic design approaches with multithreading but not well enough to ...

How can I set a breakpoint on _NSLockError()

I am trying to debug multiple threads. *** -[NSLock lock]: deadlock (<NSLock: 0xc388ab0> '(null)') *** Break on _NSLockError() to debug. How can I debug this? ...

Killing thread after some specified time limit in Java

Is there a way to kill a child thread after some specified time limit in Java? Edit: Also this particular thread may be blocked in its worst case (Thread is used to wait for a file modification and blocks until this event occurs), so im not sure that interrupt() will be successful? ...

c++ thread running time

I want to know whether I can calculate the running time for each thread. I implement a multithread program in C++ using pthread. As we know, each thread will compete the CPU. Can I use clock() function to calculate the actual number of CPU clocks each thread consumes? my program looks like: Class Thread () { Start(); Run(); Computing(...

Thread testing for time

Hi there :) I'm making a thread for my application that's going to do an exit operation at a given time (only hours and minutes, day/month doesn't matter). Is this the right way to do it, and also the right way to test for time? I'm testing for a 24 hour clock by the way, not AM / PM. I'm then in another class going to call this somethi...

Multiple threads modifying a collection in Java??

Hi, The project I am working on requires a whole bunch of queries towards a database. In principle there are two types of queries I am using: read from excel file, check for a couple of parameters and do a query for hits in the database. These hits are then registered as a series of custom classes. Any hit may (and most likely will) o...

[C#] Is variable assignment and reading atomic operation (threading)

I was unable to find any reference to this in the documentations... Is assigning to a double (or any other simple type, including boolean) an atomic operation viewed from the perspective of threads? double value = 0; public void First() { while(true) { value = (new Random()).NextDouble(); } } public void Second() { while(true) {...

Problem in suspending 2 threads at the same time in MFC!

I am learning about threading and multithreading..so i just created a small application in which i will update the progressbar and a static text using threading.I vl get two inputs from the user, start and end values for how long the loop should rotate.I have 2threads in my application. Thread1- to update the progressbar(according to th...

What does the GDI+ background thread do?

Upon initialization, GDI+ (non .NET) creates a background thread, which can optionally be suppressed subject to calling some hook functions. MSDN, however, doesn't say what this thread actually does. Google doesn't seem to know either. What is it for? ...

C# How to kill parent thread

A parent has several child threads. If user click on stop button the parent thread should be killed with all child threads. //calls a main thread mainThread = new Thread(new ThreadStart(startWorking)); mainThread.Start(); //////////////////////////////////////////////// startWorking() { ManualResetEventInstance ...

Deadlock in c++ on solaris

please anybody suggest me how to check the deadlock on solaris with command pstack ? Regards ...

Using multithreading for loop

Hello, I'm new to threading and want to do something similar to this question: http://stackoverflow.com/questions/100291/speed-up-loop-using-multithreading-in-c-question However, I'm not sure if that solution is the best one for me as I want them to keep running and never finish. (I'm also using .net 3.5 rather than 2.0 as for that qu...

Python - question regarding the concurrent use of `multiprocess`.

I want to use Python's multiprocessing to do concurrent processing without using locks (locks to me are the opposite of multiprocessing) because I want to build up multiple reports from different resources at the exact same time during a web request (normally takes about 3 seconds but with multiprocessing I can do it in .5 seconds). My ...

Looking for suggestions about an architecture of a MultiThreaded app.

Hello everyone. I am looking to develop a multithreaded application that will be running in unconditional loop and processing high volume of data. High volume is 2000+ records per minute. Processing will involve data retrieval, calculations and data updates. I need the application to perform so that there is virtually no back log, meani...

Are there some cases where Python threads can safely manipulate shared state?

Some discussion in another question has encouraged me to to better understand cases where locking is required in multithreaded Python programs. Per this article on threading in Python, I have several solid, testable examples of pitfalls that can occur when multiple threads access shared state. The example race condition provided on thi...