Skip to main content
gamedev.net
🔒 Locked

Thread Synchronization :: MFC

Started by kuphryn 2 replies 750+ views
Original Post
kuphryn
kuphryn
Hi. I am working on a program that utilizes several threads (worker threads). I want to implement a class-safe thread synchronization. In his book, Prosise uses CCriticalSection and CEvent. I would like to use CCriticalSection with CSingleLock. However, Visual C++ outputted errors when I declared the CCriticalSection and CSingleLock. For example: ----- // this is in the document class (single) ... private: ... CCriticalSection m_cs; CSingleLock m_sl; ... }; ----- Visual C++ outputted similar errors referring to both classes. Here are the errors: ----- d:\C++\MyApp\MyApp.h(96): error C2146: syntax error : missing '';'' before identifier ''m_cs'' d:\C++\MyApp\MyApp.h(96): error C2501: ''CMyAppDoc::CCriticalSection'' : missing storage-class or type specifiers d:\C++\MyApp\MyApp.h(96): error C2501: ''CMyAppDoc::m_cs'' : missing storage-class or type specifiers d:\C++\MyApp\MyApp.h(97): error C2146: syntax error : missing '';'' before identifier ''m_sl'' d:\C++\MyApp\MyApp.h(97): error C2501: ''CMyAppDoc::CSingleLock'' : missing storage-class or type specifiers d:\C++\MyApp\MyApp.h(97): error C2501: ''CMyAppDoc::m_sl'' : missing storage-class or type specifiers ----- I tried declaring both variable as protected and global. I saw the same errors. Is there something specific that I need to add to the document interface as in maybe #include <something>? Thanks, Kuphryn
IndirectX
IndirectX
Did you read the docs?

#include <afxmt.h>

---visit #directxdev on afternet <- not just for directx, despite the name
kuphryn
kuphryn
Thanks.

Kuphryn
Stoffel
Stoffel
Warning: you can''t wait on a critical section with a timeout. I think it''s a crime that MFC allows CSingleLock to use it with a timeout without throwing some error, but there ya go.

Topic Locked

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

Sign in to reply to this topic.