Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multithreading :: MFC

Started by kuphryn Aug 7, 2002 at 7:44 PM 1 replies 300+ views
Original Post
kuphryn
kuphryn
Hi. I am using multithread quite often now in my program when appropriate. According to Jeff Prosise, there are two simple ways of using multithreading correctly, especially worker threads. ----- 1: private HANDLE + duplicating thread handle upon instantiation This solution make use of ::CloseThread(...) 2: private pointer to CWinThread + delete private member This solution requires setting thread autodelete to FALSE and deleting thread manually. ----- Right now, I am using solution #2. The reason is I would know the thread is really gone because I delete, not MFC. Nonetheless, I have seen developers use both. Jeffrey Richter uses solution #1 in his book, Programming Applications for Microsoft Windows (Dv-Mps General). Are there advantages one solution has over the other? Thanks, Kuphryn
Shannon Barber
Shannon Barber
Not really, it depends on what you want to do.

I don''t think inheritence is the best way to solve the re-usable thread class though. You have to declare a new class for every thread function you want, and have to add crap to each one to communicate with the originating class.

Magmai Kai Holmlor

"Oh, like you''ve never written buggy code" - Lee

[Look for information | GDNet Start Here | GDNet Search Tool | GDNet FAQ | MSDN RTF[L] | SGI STL Docs | STFW | Asking Smart Questions ]

[Free C++ Libraries | Boost | ACE | Loki | MTL | Blitz++ | wxWindows| Spirit(xBNF)]
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
kuphryn
kuphryn
Okay. Thanks.

Kuphryn

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.