multithreading

Display "Wait" screen in WPF

I am trying to display a please wait dialog for a long running operation. The problem is since this is single threaded even though I tell the WaitScreen to display it never does. Is there a way I can change the visibility of that screen and make it display immediately? I included the Cursor call as an example. Right after I call this.Cu...

Copy-on-write with shared_ptr when multithreading

In the absence of multithreading, the implementation of copy-on-write for shared_ptr (either from boost or tr1) using unique() is straightforward. Which changes need to be made when multithreading? The reference count is atomic so I assume I can create, copy-construct, read and destroy instances of shared_ptr without further concerns. H...

Can the HWND from CreateWindow/CreateDialog be GetMessage'd from another thread?

Using the Win32 APIs, is it possible to create a Window or Dialog in one thread then collect events for it from another thread? Are HWNDs tied to threads? Trying the contrived example below I never see GetMessage() fire. HWND g_hWnd; DWORD WINAPI myThreadProc(LPVOID lpParam) { while(GetMessage( CreateThread(NULL, 0 myThreadP...

Why should I use a thread vs using a process?

I'm a newbie at this so please forgive me for my ignorance. Separating different parts of a program into different processes seems (to me) to make a more elegant program then just threading everything. In what scenario would it make sense to make things run on a thread vs separating the program into different processes? When should I ...

How to know when the work is done with CThreadPool?

I recently discovered ATL's CThreadPool class and was very happy with this find. It's a neat little class that will take care of the syncronization semantics of having multiple worker threads to process some queue of taks to do. The tasks are fed to the CThreadPool object, by some extrnal process. While being very neat an clean, there d...

What is the best way to transfer error information from worker threads under CThreadPool?

I recently discovered ATL's CThreadPool class and was very happy with this find. It's a neat little class that will take care of the syncronization semantics of having multiple worker threads to process some queue of taks to do. The tasks are fed to the CThreadPool object, by some extrnal process. Now suppose one of the worker threads e...

Synchronization for multiple readers, single writer?

Another synchronization question...I hope you guys don't get annoyed ;) Assume the following scenario: one central data structure (very large, so I don't really want to make it immutable and copy it around whenever a change occurs. I even don't want to keep multiple copies in memory), multiple reader threads that access that data struct...

Rules for finding / avoiding shared data in a multithreaded application

Hy, as we all know, developing a multithreading application is a hard thing. Especially the point when and what to lock is not so obvious IMHO. Often I'm looking at a method / class and I must ask myself, if I share some data, which can be modified by multiple threads. And when I'm not sure it ends in a lock( ) over a whole code block. ...

CreateThread vs fork()

Do we have any sort of relationship between fork() and CreateThread? Is there anything that CreateThread internally calls fork()? ...

Why is my Panel's repaint not being called?

I've got a problem which I just can't seem to get around involving a small animation. For a project we are designing a J9 application to run on a PDA (DELL Axim X51). The problematic code (shown below) is when a mouse click is detected to run a small animation in a nested panel. If the animation is run independently of the mouse click, i...

Debugging multithreaded applications

I have an application written in C++ and MFC which is multithreaded running on windows. Occasionally I do get some complaints such as deadlocks or an unhandled exception which is caused because of these threads. Normally I use visual studio (if the problem is reproducible) or else use the WinDbg to analyse the dump files generated. Is th...

iPhone Gameloop render update from a separate thread

Hi, I'm new to iPhone development. I have a game loop setup as follows. (void)CreateGameTick:(NSTimeInterval) in_time { [NSThread detachNewThreadSelector:@selector(GameTick) toTarget:self withObject:nil]; } My basic game tick/render looks like this (void)GameTick { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; C...

How can I set the max number of mysql processes or threads?

ps axuw| grep mysql indicates only mysql process but if I run htop I can see 10 rows each one of them with a separate PID. So I wonder if they are threads or processes that for some reason I cannot see using ps. Would it make any sense to try to limit them to 2 on my development machine where I don't need concurrent access of many clien...

.Net Not Responding, Application.DoEvents and Threading

My mdi VB.Net application performs a long operation on some data. Ideally I should use a separate thread to prevent the dreaded “Not Responding” message. My problem is if I use a separate thread users then have the ability to click on other controls in the application which can directly affect the operation my background thread is worki...

Why would pthread_create() fail with only 2 threads active?

I'm having some trouble in my first foray into threads in C. I'm trying (for now) to write a very simple server program that accepts a socket connection and starts a new thread to process it. It seems to work fine except that it will only create about 300 threads (303, sometimes 304) before pthread_create() fails with the EAGAIN code, wh...

For my app, how many threads would be optimal?

I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is, how many should i ...

How can I use OpenOffice in server mode as a multithreaded service?

What is the experience of working with OpenOffice in server mode? I know OpenOffice is not multithreaded and now I need to use its services in our server. What can I do to overcome this problem? I'm using Java. ...

Spurious unblocking in boost thread

I came across this interesting paragraph in the Boost thread documentation today: void wait(boost::unique_lock<boost::mutex>& lock) ... Effects: Atomically call lock.unlock() and blocks the current thread. The thread will unblock when notified by a call to this->notify_one() or this->notify_all(), or spuriously. When the...

python conditional lock

How can I implement conditional lock in threaded application, for instance I haw 30 threads that are calling function and for most off the time all threads can access is simultaneous, but depending on function input there can be condition when only one thread can do that one thing. (If value for input is repeated and some thread is stil...

Why does my session variable appear to empty itself in ASP.NET?

I have user control on a ASP.NET web page, which contains a GridView and a radio button selector. In the underlying middle tier I have a thread which goes to the database and then raises an event to say "I have some data" my User control handles this event and sets a Session Variable. This works and I can see the event being handle...