Click here to Skip to main content
16,005,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDatabase connectivity Pin
Nath_Vishwa25-Dec-08 19:26
Nath_Vishwa25-Dec-08 19:26 
AnswerRe: Database connectivity Pin
Girish60125-Dec-08 20:13
Girish60125-Dec-08 20:13 
AnswerRe: Database connectivity Pin
Mark Salsbery26-Dec-08 10:07
Mark Salsbery26-Dec-08 10:07 
QuestionNeed some suggestion to develop a visio-like app using MFC Pin
yybenny25-Dec-08 17:13
yybenny25-Dec-08 17:13 
GeneralRe: Need some suggestion to develop a visio-like app using MFC Pin
Luc Pattyn25-Dec-08 17:32
sitebuilderLuc Pattyn25-Dec-08 17:32 
GeneralRe: Need some suggestion to develop a visio-like app using MFC Pin
yybenny25-Dec-08 19:26
yybenny25-Dec-08 19:26 
GeneralRe: Need some suggestion to develop a visio-like app using MFC Pin
yybenny25-Dec-08 20:48
yybenny25-Dec-08 20:48 
QuestionIs This Thread Safe Pin
BobInNJ25-Dec-08 16:26
BobInNJ25-Dec-08 16:26 
I am writing any application using C++ and MFC. Please consider the following two class member functions:

<br />
	void ReportASuccess()<br />
	{<br />
		successCount ++;<br />
		this->Invalidate();<br />
	}<br />
<br />
	void ReportAFailure()<br />
	{<br />
		failCount ++;<br />
		this->Invalidate();<br />
	}<br />


There two functions will be called many thousands of times by several worker threads to report results. I am concerned that the increment of the counters successCount and failCount is not thread safe. That is, if the thread loses focus in the middle of the increment, there could be a problem. Do I need to worry about this, and if so, what is the way around it?

By the way, the two member functions shown above are part of class that handles the GUI.

Thanks

Bob
GeneralRe: Is This Thread Safe Pin
Luc Pattyn25-Dec-08 17:29
sitebuilderLuc Pattyn25-Dec-08 17:29 
AnswerRe: Is This Thread Safe Pin
Code-o-mat25-Dec-08 22:51
Code-o-mat25-Dec-08 22:51 
GeneralRe: Is This Thread Safe Pin
BobInNJ26-Dec-08 6:16
BobInNJ26-Dec-08 6:16 
GeneralRe: Is This Thread Safe Pin
Code-o-mat26-Dec-08 7:57
Code-o-mat26-Dec-08 7:57 
GeneralRe: Is This Thread Safe Pin
BobInNJ26-Dec-08 8:28
BobInNJ26-Dec-08 8:28 
GeneralRe: Is This Thread Safe Pin
Mark Salsbery26-Dec-08 10:20
Mark Salsbery26-Dec-08 10:20 
GeneralRe: Is This Thread Safe Pin
Code-o-mat26-Dec-08 10:56
Code-o-mat26-Dec-08 10:56 
GeneralRe: Is This Thread Safe Pin
Mark Salsbery26-Dec-08 11:27
Mark Salsbery26-Dec-08 11:27 
GeneralRe: Is This Thread Safe Pin
Code-o-mat26-Dec-08 10:38
Code-o-mat26-Dec-08 10:38 
Questioncannot delete CStringArray like this? [modified] Pin
kaviniswell25-Dec-08 15:58
kaviniswell25-Dec-08 15:58 
AnswerRe: cannot delete CStringArray like this? Pin
kaviniswell25-Dec-08 16:12
kaviniswell25-Dec-08 16:12 
AnswerRe: cannot delete CStringArray like this? Pin
BobInNJ25-Dec-08 16:38
BobInNJ25-Dec-08 16:38 
GeneralRe: cannot delete CStringArray like this? [modified] Pin
kaviniswell25-Dec-08 17:31
kaviniswell25-Dec-08 17:31 
GeneralRe: cannot delete CStringArray like this? Pin
kaviniswell25-Dec-08 17:45
kaviniswell25-Dec-08 17:45 
GeneralRe: cannot delete CStringArray like this? Pin
Richard Andrew x6426-Dec-08 0:40
professionalRichard Andrew x6426-Dec-08 0:40 
GeneralRe: cannot delete CStringArray like this? Pin
kaviniswell26-Dec-08 1:23
kaviniswell26-Dec-08 1:23 
Questionwindow in thread Pin
dene9997025-Dec-08 13:00
dene9997025-Dec-08 13:00 

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.