multithreading

EntLib Logging via email in Windows Service (not async?)

I'm writing a windows service and attempting to do some logging via enterprise library 4.0. Logs go to the event log and email. The event log entries get written fine but emails are only sent after I stop the service. So I could have 30 exceptions occur, log them and no emails would be sent until I shut it down. Then a few minutes later...

Windows Threads: when should you use InterlockedExchangeAdd()?

The naming of this function seems like this is some complicated stuff going on. When exactly does one know that this is the way to go instead of doing something like this: Preparation CRITICAL_SECTION cs; int *p = malloc(sizeof(int)); // Allocation Site InitializeCriticalSection(&cs); // HINT for first Write Thread #1 ...

ObjectDisposedException - running stopwatch in GUI thread

I have a stopwatch running in a different thread, that updates the GUI thread in a label to show as time goes by. When my program closes, it throws a ObjectDisposedException when I call this.Invoke(mydelegate); in the Form GUI to update the label with the time from the stopwatch. How do I get rid of this ObjectDisposedException? I...

Are there any practical alternatives to threads?

While reading up on SQLite, I stumbled upon this quote in the FAQ: "Threads are evil. Avoid them." I have a lot of respect for SQLite, so I couldn't just disregard this. I got thinking what else I could, according to the "avoid them" policy, use instead in order to parallelize my tasks. As an example, the application I'm currently worki...

Strategies for concurrent pipelines in Java

Consider the following shell script: gzip -dc in.gz | sed -e 's/@/_at_/g' | gzip -c > out.gz This has three processes working in parallel to decompress a stream, modify it, and re-compress it. Running time I can see my user time is about twice that of my real time, which indicates the program is effectively working in parallel. I'...

stopping dll loop

I have a multi-thread C# application that uses some recursive functions in a dll. The problem that I have is how to cleanly stop the recursive functions. The recursive functions are used to traverse our SCADA system's hierarchical 'SCADA Object' data. Traversing the data takes a long time (10s of minutes) depending on the size of our ...

Implementing a job list with internal synchronisation

I'm working on a simple job threading framework which is very similar to the one described in id Tech 5 Challenges. On the most basic level, I have a set of lists of jobs, and I want to schedule these list across a bunch of CPU threads (using a standard thread pool for the actual dispatching.) However, I wonder how this signal/wait stuff...

my_thread_global_end threads didn't exit, error?

I am using MySQL c++ connector (1.0.5) , recently I moved get_driver_instance() and connect() methods to secondary thread then I am getting below error. Error in my_thread_global_end(): 1 threads didn't exit After googling I found that mysql thread isn't exiting. Is there a method in c++ wrapper to do cleanup? ...

Python thread for pre-importing modules

I am writing a Python application in the field of scientific computing. Currently, when the user works with the GUI and starts a new physics simulation, the interpreter immediately imports several necessary modules for this simulation, such as Traits and Mayavi. These modules are heavy and take too long to import, and the user has to wai...

outputting to cin from a worker thread (c++)

Hi, My program has a main thread that takes command input from a user. Separately, it has potentially multiplie (at least 1) worker threads churning data in the background. The user is able to terminate the program using a command by typing into the console. However, when the data churning is done, the main thread is still blocking wa...

What is the threading class if I just want to test and set a flag in a threadsafe manner?

I just want to do a simple, though thread-safe, boolean test (and set) so: if(myBoolean==false) //should not lock/wait! { myBoolean=true; ..... } else { .... } I considered the following (although possibly incorrectly, so please correct me where I misunderstood) using the Lock { if(myBoolean)... } construct seems ...

emit Qt signal from non Qt Thread or ouside Qt main event loop with at 4.5

Hi, I'm calling a "emit signal1()" from a non Qt thread. By non Qt thread I mean not from the GUI Event Loop and not from any QThread run() method or any QThread own event loop. It is simply a pthread (pthread_create()) that calls a method of a QObject which emits signals. ex: MyQbject: public QObject { ... void emitBunchOfSignals() ...

Why doesn't my threaded .Net app scale linearly when allocating large amounts of memory?

I’ve run into something strange about the effect of large memory allocations on the scalability of the .Net runtime. In my test application I create lots of strings in a tight loop for a fixed number of cycles and spit out a rate of loop iterations per second. The weirdness comes in when I run this loop in several threads – it appears th...

C# WinForms - Possible to construct form on background thread, then display on UI thread

UPDATE: Just to summarize what my question has boiled down to: I was hoping that constructing .NET forms and controls did NOT create any window handles -- hoping that process was delayed until Form.Show/Form.ShowDialog Can anyone confirm or deny whether that is true? I've got a large WinForms form with tab control, many many control...

Call stack memory architecture

Following my question yesterday, I tried to learn a bit more about the architecture of call stacks. Online and SO searches have not yielded the answer I'm looking for, which could be because I don't know precisely which keywords to use. Anyway, I'm sure someone here can help me... First, lets start with an excerpt from Wikipedia's entry...

how to return from a blocked call ?

is it possible to force a thread to return from a call to a blocking function such as a blocking read from a stream ? int x; std::cin >> x; for example... ...

How to speedup python unittest on muticore machines?

I'm using python unittest in order to test some other external application but it takes too much time to run the test one by one. I would like to know how can I speedup this process by using the power of multi-cores. Can I tweak unittest to execute tests in parallel? How? This question is not able python GIL limitation because in fact...

java matrix-multiplication (FAST)

I have to multiply 2 (most of the times) sparse matrix. Those matrix are pretty bit (about 10k*10k) and i've a two Xeon Quad core and just one thread for this job? is there any fast library for multi-thread moltiplication? any other advice? ...

Closing a stream in a thread that is already running [C#]

I have multiple downloads running in threads. I want to close the stream, say when user hits pause/stop download. How could I close the filestream of a download running in a thread? ...

C# ThreadStaticAttribute marked fields are automatically released when thread dies?

I discovered 'ThreadStaticAttribute', and I have a lot of questions about it: all my previous thread dependent static informations, were implemented as a static dictionary wich TKey is Thread, and when I wanted to access it, I used Thread.CurrentThread and that works. But this requires mantainance, because if a thread dies, I have to del...