multithreading

Threading pattern: Chaining and looping

Hi, I need to use a WCF API to save data into a DB. Ordinarily, I'd use chaining, like the example below: IClientBroker clientBroker = UIContext.CreateWcfInterface<IClientBroker>("Data/ClientBroker.svc"); clientBroker.BeginSetClientBusinessName(_client.ID, businessName, (result) => { _client = ((IClientBroker)result.AsyncState)....

Multithreaded Windows service in MingW

I am trying to build a Windows service with MingW. It need thread safe exceptions, so I added the linker flag -mthreads. The application works fine from the command-line, but when I try to start it from services.msc, the 1054 error ("The service did not respond to the start or control request in a timely fashion") is raised. The service ...

C#: Where does Control.BeginInvoke run?

What does that method do exactly? I was thinking that it maybe went out into a separate thread, but handled things like control updating on the correct thread. But now I am starting to think that it maybe just runs on the UI thread. Which means that calling BeginInvoke on a control from the UI is pretty much the same as calling Invoke? O...

How to do work outside of main gui thread?

I have an object that when you instantiate it and send it a message it takes a long time to run. It is designed to call back a delegate object with the results of the job. There are multiple calls back to the delegate over time. I know I need to put the job in a thread. I know how to make a thread. I know that if a thread wants to send...

Unit Testing WPF UserControls

Is it possible to test my WPF UserControls from NUnit (or similar)? If I create an instance of the usercontrol in a unit test like so: // Create an instance of the WPF UserControl var view = new ChildrenListView(); I get the following error: "The calling thread must be STA, because many UI components require this" I get the feeling...

How do you enable hibernate query cache on a session level only?

Good day, What if I have a query that gets called multiple times in a single thread, and I just want to cache that query (and its result) for that thread (or for that session since I'm using one session per thread), how can I do that ? Note: My 2nd level cache is turned on but it's used mostly for session.get(...). But I do not want to...

How to use native C types with performSelectorOnMainThread:?

I'd like to call (void)setDoubleValue:(double)value using performSelectorOnMainThread:. What I thought would work is: NSNumber *progress = [NSNumber numberWithDouble:50.0]; [progressIndicator performSelectorOnMainThread:@selector(setDoubleValue:) withObject:progress w...

Thread was being aborted

I am using Server.Transfer. Everything works fine, but exception log shows following exception. System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End() at System.Web.HttpServerUtility.Transf...

Thread error in Python & PyQt

I noticed that when the function setModel is executed in parallel thread (I tried threading.Timer or threading.thread), I get this: QObject: Cannot create children for a parent that is in a different thread. (Parent is QHeaderView(0x1c93ed0), parent's thread is QThread(0xb179c0), current thread is QThread(0x23dce38) QObject::startTimer:...

Multi threaded FFTW 3.1.2 on a shared memory computer

I use FFTW 3.1.2 with Fortran to perform real to complex and complex to real FFTs. It works perfectly on one thread. Unfortunately I have some problems when I use the multi-threaded FFTW on a 32 CPU shared memory computer. I have two plans, one for 9 real to complex FFT and one for 9 complex to real FFT (size of each real field: 512*512...

Multi-threading the formatting of datagridview rows?

I've read a number of examples on using BackgroundWorker objects to handle executing time-intensive tasks which generate results which are used to populate a DataGridView. However in my case it seems as though the act of populating the DataGridView is what's taking the most time. I'm wondering if this is because I need to format the re...

Do C# Timers elapse on a separate thread?

Does a System.Timers.Timer elapse on a separate thread than the thread that created it? Lets say I have a class with a timer that fires every 5 seconds. When the timer fires, in the elapsed method, some object is modified. Lets say it takes a long time to modify this object, like 10 seconds. Is it possible that I will run into thread co...

specifying ThreadPoolExecutor problem

Is there any way to create Executor that will have always at least 5 threads, and maximum of 20 threads, and unbounded queue for tasks (meaning no task is rejected) I tried new ThreadPoolExecutor(5, 20, 60L, TimeUnit.SECONDS, queue) with all possibilities that I thought of for queue: new LinkedBlockingQueue() // never runs more than 5 ...

How many threads does it take to make them a bad choice?

I have to write a not-so-large program in C++, using boost::thread. The problem at hand, is to process a large (maybe thousands or tens of thousands. Hundreds and millons are a possibility as well) number of (possibly) large files. Each file is independent from another, and they all reside in the same directory. I´m thinking of using th...

Multithreaded chat-server in Java

I'm trying to implement a server-client socket program in Java that can support multiple clients, but my class that performs the multithreading always crashes whenever my client connects to my server. import java.io.*; import java.net.*; public class ClientWorker extends Thread{ Socket cwsocket=null; public ClientWorker(Socket...

Multiple Producers, Multiple Consumers and Store Problem

I have a scenario where Multiple Producers are running on different machines in a Network. These are Singleton WCF Services which are queuing the Products (Output) in the Central Store which is also a Singleton WCF Service. There are consumers who dequeue the product from the Central Store by calling the Central Store via a JSON Request...

Single or multiple thread pools for Java server?

I am writing a fairly complex Java server application which has a significant background processing portion in addition to the usual request-response processing. Some of the background processing is done in a cron-like fashion using Quartz framework. Other tasks are more of on demand - if a new client connects it creates additional job f...

Is it possible to use Qt threading without inheriting any Qt object?

The only way to enable threading demonstrated in qt documentation is through inheriting QThread and then override its run() method. class MyThread : public QThread { public: void run(); }; void MyThread::run() { QTcpSocket socket; // connect QTcpSocket's signals somewhere meaningful ... socket.connectToHos...

Working around fls limitations with too many statically linked CRTs?

When loading external DLLs (not under our control) via LoadLibrary, we're hitting a problem where the statically linked CRT in those DLLs are failing to allocate fiber-local storage. This is similar to mskb 193462, except that this is FLS and there's only 128 of them. Are there any useful ways to work around the problem? The CRT is usi...

Converting old C code to work with threads.

I have a very old, very very large, fully working, C program which plays a board game. I want to convert it (or should I say parts of it) to work in multiple threads, so that I can take advantage of multi-core processors. In the old program there is a global UBYTE array called board[]. There are a great many (highly optimized, highly spe...