multithreading

SOLVED threading in a dll where the dll must return before child thread finishes

I am working on writing a wrapper dll to interface a communication dll for a yokogawa WT1600 power meter, to a PC based automation package. I got the communication part to work but I need to thread it so that a 50ms scan time of the automation package can be maintained. (The Extended Function Block (EFB) Call will block the scan until it...

Handling Unhandled errors that happen in a secondary threaded process.

I have a asp.net 2.0 web app which calls a long running stored proc (about 3 minutes). The sp actually performs many tasks on the backend. My page uses threading and ajax (update panel) and a timer control to dispaly a progess bar to the user. This all works great unless there is an error in the sp which just freezes the screen. I ha...

How to recover gracefully from TargetInvocationException in multi thread?

I got TargetInvocationException while doing long process in another thread caused by a windows control on UI thread (Progress Bar). This exception leads my app to crash (goes to main method in debugging) and could not be caught by try catch. I figured out what made this exception, and fix it (that was trying to assign “Value” property by...

How to use threads and queue in VC++

I want to use two queues where the 1st queue will push the data to the queue and the 2nd thread will remove the data from the queue. Can somebody help me plz on implementing this in VC++? I am new to the threads and queue. ...

Dynamically refresh JTextArea as processing occurs?

I am trying to create a very simple Swing UI that logs information onto the screen via a JTextArea as processing occurs in the background. When the user clicks a button, I want each call to: textArea.append(someString + "\n"); to immediately show up in the UI. At the moment, the JTextArea does not show all log information until the ...

Calling synchronous methods asynchronously on the UI thread

Hello I have written a class that checks a POP3 account and I'd like it to execute on a thread other than the UI thread. To do this, I've chosen the asynchronous route. In order to get the result from pop3delegate.BeginInvoke(null,null) I need to call EndInvoke but doing this in the UI thread blocks rendering the UI unusable. I could...

Interruptible thread join in Python

Is there any way to wait for termination of a thread, but still intercept signals? Consider the following C program: #include <signal.h> #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <pthread.h> #include <stdlib.h> void* server_thread(void* dummy) { sleep(10); printf("Served\n"); return NULL; } v...

Control property not found in WPF, but present in VB.net WindowsForms

Guys, WPF project is not accepting this property definition when starting a thread. Anybody knows the equivalent of the following in WPF? Control.CheckForIllegalCrossThreadCalls = False Thanks in advance! ...

Log4j is hanging my application what am I doing wrong?

First some background on the application. I have an application processing many independent tasks in parallel via a thread pool. The thread pool is now hanging. The following is an snippet from my thread dumps, all my Threads in pool-2 are BLOCKED by "pool-2-thread-78". It seems to be locked trying to write to the console which I find e...

How do I properly cancel and restart a BackgroundWorker process?

Users of my application type HTML into a TextBox control. I want my application to validate their input in the background. Because I don't want to hammer the validation service, I've tried to build in a one-second delay before each validation. However, I don't seem to be able to correctly interrupt an already-running BackgroundWorker ...

Profiling C++ multi-threaded applications

Have you used any profiling tool like Intel Vtune analyzer? What are your recommendations for a C++ multi threaded application on Linux and windows? I am primarily interested in cache misses, memory usage, memory leaks and CPU usage. I use valgrind (only on UNIX), but mainly for finding memory errors and leaks. ...

Delphi: TWebBrowser in background-thread

Is it possible to load a webpage in a TWebBrowser in a background thread? When the application loads, I want to download a page from the web into a TWebBrowser, but I don't want to block the gui-thread. Any suggestions? Some clarifications: The webbrowser-component is living on a form, and i want to display a page from the web. But I...

Is there anything dangerous about using Thread.currentThread.sleep() in my main code?

in my code I'm using Thread.currentThread().sleep(sleepTime); in the main (non Thread object) portion of the code. It appears to be working fine, but I'm worried that there might be some hidden pitfall that will bite me in the ass later. Is there a better way to make your main process sit around for a while? or is this the prescribe...

How to use multiple threads to process an image in sections?

I am trying to quickly process large images (about 2000x2000). I am using a TrackBar to change the overall brightness of an image. The problem is that the TrackBar (as you all know) can be moved very quickly. This is ok as I do not need to process the image for every tick of the TrackBar, but it does need to be reasonably responsive. ...

Are threading issues for C/C++ "system level programmers" significantly different from those faced by Java programmers?

I'm looking for a development job and see that many listings specify that the developers must be versed in multithreading. This appears both for Java job listings, and for C++ listings that involve "system programming" on UNIX. In the past few years I have been working with Java and using its various synchronization mechanisms. In the...

How to use queue with two threads-- one for consumer and one for producer

Hi, I am using a application where lower level application always invokes a callback RecData(char *buf) when it receives the data. Now in the call back i am creating two threads and pass the consumer and producer function to these created threads respectively. My code looks like as below: void RecData (char * buf) { CreateThread(NULL,...

C: pattern for returning asynchron error from background thread?

I'm writing an open source C library. This library is quite complex, and some operations can take a long time. I therefore created a background thread which manages the long-running tasks. My problem is that I have not yet found an elegant way to return errors from the background thread. Suppose the background thread reorganizes a file ...

How can I make sure N threads run at roughly the same speed?

I'm toying with the idea of writing a physics simulation software in which each physical element would be simulated in its own thread. There would be several advantages to this approach. It would be conceptually very close to how the real world works. It would be much easier to scale the system to multiple machines. However, for this t...

Memory leaks in a multi-threaded application using COM & C#

I have written a multi thread unmanaged application which uses COM objects in its worker threads. Everything went fine until I started using .NET objects exported as COM to do the work. Playing around with the code and commenting out parts of the .NET object functionality I managed to pin it down to the usage of COM objects from within...

terminating a secondary thread from the main thread (cocoa)

Hello I'm working on a small app written in objective-c with the help of the cocoa framework and I am having a multithreading issue. I would really appreciate it if somebody could help me with some guidance on how terminate a secondary(worker) thread from the main thread? - (IBAction)startWorking:(id)sender { [NSThread detachNewTh...