Click here to Skip to main content
15,921,941 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: I just don't understand HWND Pin
«_Superman_»16-Oct-09 8:44
professional«_Superman_»16-Oct-09 8:44 
GeneralRe: I just don't understand HWND Pin
GLGunblade16-Oct-09 8:52
GLGunblade16-Oct-09 8:52 
GeneralRe: I just don't understand HWND Pin
Richard MacCutchan16-Oct-09 9:05
mveRichard MacCutchan16-Oct-09 9:05 
GeneralRe: I just don't understand HWND Pin
GLGunblade16-Oct-09 9:11
GLGunblade16-Oct-09 9:11 
QuestionRe: I just don't understand HWND Pin
CPallini16-Oct-09 10:52
mveCPallini16-Oct-09 10:52 
AnswerRe: I just don't understand HWND Pin
GLGunblade16-Oct-09 17:39
GLGunblade16-Oct-09 17:39 
GeneralRe: I just don't understand HWND Pin
Richard MacCutchan16-Oct-09 22:19
mveRichard MacCutchan16-Oct-09 22:19 
GeneralRe: I just don't understand HWND Pin
GLGunblade17-Oct-09 15:10
GLGunblade17-Oct-09 15:10 
QuestionDDX_CONTROL VS. Create for the RichEditClass Pin
ForNow16-Oct-09 6:33
ForNow16-Oct-09 6:33 
AnswerRe: DDX_CONTROL VS. Create for the RichEditClass Pin
Iain Clarke, Warrior Programmer16-Oct-09 22:06
Iain Clarke, Warrior Programmer16-Oct-09 22:06 
GeneralRe: DDX_CONTROL VS. Create for the RichEditClass Pin
ForNow17-Oct-09 14:22
ForNow17-Oct-09 14:22 
GeneralRe: DDX_CONTROL VS. Create for the RichEditClass Pin
ForNow17-Oct-09 17:41
ForNow17-Oct-09 17:41 
Questionhow to work out "type redefinition" problem Pin
yugiant16-Oct-09 4:57
yugiant16-Oct-09 4:57 
AnswerRe: how to work out "type redefinition" problem Pin
«_Superman_»16-Oct-09 5:05
professional«_Superman_»16-Oct-09 5:05 
GeneralRe: how to work out "type redefinition" problem Pin
yugiant16-Oct-09 5:51
yugiant16-Oct-09 5:51 
GeneralRe: how to work out "type redefinition" problem Pin
«_Superman_»16-Oct-09 6:03
professional«_Superman_»16-Oct-09 6:03 
GeneralRe: how to work out "type redefinition" problem Pin
yugiant16-Oct-09 6:06
yugiant16-Oct-09 6:06 
QuestionRe: how to work out "type redefinition" problem Pin
David Crow16-Oct-09 5:05
David Crow16-Oct-09 5:05 
Questionhow to get dial-in tab properties of user object in active directory using c++ Pin
raja 416-Oct-09 4:40
raja 416-Oct-09 4:40 
QuestionChild dialog problem Pin
ilgale16-Oct-09 4:26
ilgale16-Oct-09 4:26 
AnswerRe: Child dialog problem Pin
Iain Clarke, Warrior Programmer16-Oct-09 22:07
Iain Clarke, Warrior Programmer16-Oct-09 22:07 
QuestionHow do I make calling InitializeCriticalSection() thread safe? [modified] Pin
Steve Thresher16-Oct-09 2:06
Steve Thresher16-Oct-09 2:06 
I have a static class I use for caching data. This will now be accessed from multiple threads which means I need to add a CRITICAL_SECTION to make updating the cache thread safe. I now have the problem of who initialises the CRITICAL_SECTION given a static class doesn't have a constructor.

std::map<int,std::string> CMY_CACHE::m_cache_map;

CRITICAL_SECTION CMY_CACHE::m_critical_section;

class CMY_CACHE
{
private:
  static std::map<int,std::string> m_cache_map;

  static CRITICAL_SECTION m_critical_section; //<-- Where do I initialize this?

public:
    
std::string read(int index)
{
  EnterCriticalSection(&m_critical_section);

  std::map<int,std::string>::iterator it=m_cache_map.find(index);
  
  if (it==m_cache_map.end())
  {
    // Add value to cache

    // Adjust iterator
  }

  LeaveCriticalSection(&m_critical_section);


  return(it->second);
}

...

  // The following call could be issued by multiple threads
  std::string s=CMY_CACHE::read(0);


modified on Friday, October 16, 2009 8:28 AM

AnswerRe: How do I make calling InitializeCriticalSection() thread safe? Pin
Cedric Moonen16-Oct-09 2:32
Cedric Moonen16-Oct-09 2:32 
AnswerRe: How do I make calling InitializeCriticalSection() thread safe? Pin
CPallini16-Oct-09 2:54
mveCPallini16-Oct-09 2:54 
AnswerRe: How do I make calling InitializeCriticalSection() thread safe? Pin
cmk16-Oct-09 3:02
cmk16-Oct-09 3:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.