CRITICAL_SECTION and OnPaint, OnMouseWheel...
Posted on 2006-03-27
I'm using CRITICAL_SECTIONs to make sure that my code in OnPaint and OnMouseWheel and OnLButtonClick, etc, runs in their entirety before events call one of the other functions: (OnMouseWheel, OnLButtonClick, OnPaint)... i.e., when I'm in one, I don't want to be in the other... I'm getting problems of memory being overwritten and scalars deleting descructors.
My question is this: First of all, is CRITICAL_SECTION what I'm SUPPOSED to be using for this? Because it's my understanding that the GUI thread is not interruptable - and there's really only 1 thread running in an MFC app... CRITICAL_SECTION protects you from MULTIPLE threads accessing the same piece of code simultaneously.... So is what I'm doing with CRITICAL_SECTION useless in this case? Is there only one thread here?? If my OnPaint is called, can my OnMouseWheel get called before OnPaint is finished? How do I prevent this properly??
Thank you so much!