Click here to Skip to main content
15,901,284 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Where is WM_INITDIALOG [modified] Pin
DRHuff4-Apr-07 5:11
DRHuff4-Apr-07 5:11 
AnswerRe: Where is WM_INITDIALOG Pin
Ranjoy Guha4-Apr-07 5:12
Ranjoy Guha4-Apr-07 5:12 
QuestionMacros Pin
koumodaki4-Apr-07 4:31
koumodaki4-Apr-07 4:31 
AnswerRe: Macros Pin
Ravi Bhavnani4-Apr-07 4:38
professionalRavi Bhavnani4-Apr-07 4:38 
GeneralRe: Macros Pin
koumodaki4-Apr-07 4:49
koumodaki4-Apr-07 4:49 
AnswerRe: Macros Pin
Ranjoy Guha4-Apr-07 4:56
Ranjoy Guha4-Apr-07 4:56 
GeneralRe: Macros Pin
koumodaki4-Apr-07 5:34
koumodaki4-Apr-07 5:34 
QuestionCRITICAL_SECTION Question Pin
ScotDolan4-Apr-07 4:09
ScotDolan4-Apr-07 4:09 
I have serial application, that has it's own thread that polls the serial devices. The thread reads values from the devices and storages them in a private variable. In that thread, when accessing that private variable I critical lock and unlock the variable. I also have public member function that reads that private data member. The member function is used to provide the application with access to value of the private data member. This read does not occur in the same thread.

However, because i am only reading this variable is it still necessary to critical lock and unlock this variable in the public member function?
<br />
<br />
void LENZE_8200_MOTION::ThreadRun(void)<br />
{	<br />
<br />
<br />
   while(1)<br />
   {<br />
   /......./<br />
	case LNZ82_OUTPUT_CURRENT:<br />
	cResults = get_output_current(lift_address, &dTemp ); // This function takes 2-3secs to complete this is way the dTemp is passed in and not m_dLiftOutputCurrent<br />
	EnterCriticalSection(&m_csLiftLock);	// acquires ownership of a critical section <br />
	m_dLiftOutputCurrent = dTemp;		<br />
	if( cResults >= 0 ){<br />
	     lift_cmd.Pop( &cmd );// Removes pending command from the to be process que	<br />
	     m_lLiftFailedTxPktSeqCount = 0;// Clears Increments Connectivity Failed Packet Count<br />
	}else{ <br />
	     m_lLiftFailedTxPktSeqCount++;// Increments Connectivity Failed Packet Count<br />
	     m_lLiftFailedTxPktAccumCount++;// Increments the total failed pkt count<br />
	}<br />
	LeaveCriticalSection(&m_csLiftLock);// releases ownership of a critical section <br />
	break;<br />
<br />
	case LNZ82_OPERATING_TEMPERATURE:<br />
	cResults = get_temperature(lift_address, &dTemp );// This function takes 2-3secs to complete this is way the dTemp is passed in and not m_dLiftOutputTemperature <br />
	EnterCriticalSection(&m_csLiftLock);	// acquires ownership of a critical section 		m_dLiftOutputTemperature = dTemp;<br />
	if( cResults >= 0 ){<br />
	    lift_cmd.Pop( &cmd );// Removes pending command from the to be process que	<br />
	    m_lLiftFailedTxPktSeqCount = 0;// Clears Increments Connectivity Failed Packet Count<br />
	}else{ <br />
	    m_lLiftFailedTxPktSeqCount++;// Increments Connectivity Failed Packet Count<br />
	    m_lLiftFailedTxPktAccumCount++;// Increments the total failed pkt count<br />
	    m_dLiftOutputTemperature = -1;<br />
	}<br />
	LeaveCriticalSection(&m_csLiftLock);	// releases ownership of a critical section <br />
	break;<br />
<br />
<br />
  <br />
   /......../<br />
 }<br />
<br />
}<br />
<br />
<br />
<br />
double LENZE_8200_MOTION::lift_get_output_current(void)<br />
{ <br />
  double temp;<br />
  ???????? Do i need critical lock here<br />
  temp = m_dLiftOutputCurrent;<br />
  ???????? Do i need critical unlock here <br />
  return temp; <br />
};<br />
<br />
<br />
double LENZE_8200_MOTION::lift_get_output_temperature(void)<br />
{ <br />
    ???????? Do i need critical lock here<br />
    return m_dLiftOutputTemperature; <br />
  ???????? Do i need critical unlock here <br />
}<br />
<br />


Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures

AnswerRe: CRITICAL_SECTION Question Pin
Blake Miller4-Apr-07 4:29
Blake Miller4-Apr-07 4:29 
AnswerRe: CRITICAL_SECTION Question Pin
Roger Stoltz4-Apr-07 4:37
Roger Stoltz4-Apr-07 4:37 
QuestionCToolBarCtrl::SetRows Pin
Try4-Apr-07 3:44
Try4-Apr-07 3:44 
AnswerRe: CToolBarCtrl::SetRows Pin
Ravi Bhavnani4-Apr-07 4:41
professionalRavi Bhavnani4-Apr-07 4:41 
GeneralRe: CToolBarCtrl::SetRows Pin
Try4-Apr-07 4:48
Try4-Apr-07 4:48 
AnswerRe: CToolBarCtrl::SetRows Pin
Ranjoy Guha4-Apr-07 4:49
Ranjoy Guha4-Apr-07 4:49 
Question[Urgent]Minimize window clicking task bar button [modified] Pin
ksrameshkanth4-Apr-07 3:44
ksrameshkanth4-Apr-07 3:44 
AnswerRe: [Urgent]Minimize window clicking task bar button Pin
Try4-Apr-07 4:17
Try4-Apr-07 4:17 
GeneralRe: [Urgent]Minimize window clicking task bar button Pin
ksrameshkanth4-Apr-07 4:25
ksrameshkanth4-Apr-07 4:25 
Questionfunction malloc() on c++ ...can you help me please... Pin
lavy28834-Apr-07 3:32
lavy28834-Apr-07 3:32 
AnswerRe: function malloc() on c++ ...can you help me please... Pin
Michael Dunn4-Apr-07 3:42
sitebuilderMichael Dunn4-Apr-07 3:42 
GeneralRe: function malloc() on c++ ...can you help me please... Pin
lavy28834-Apr-07 4:10
lavy28834-Apr-07 4:10 
GeneralRe: function malloc() on c++ ...can you help me please... Pin
Michael Dunn4-Apr-07 4:20
sitebuilderMichael Dunn4-Apr-07 4:20 
GeneralRe: function malloc() on c++ ...can you help me please... Pin
David Crow4-Apr-07 4:28
David Crow4-Apr-07 4:28 
GeneralRe: function malloc() on c++ ...can you help me please... Pin
lavy28834-Apr-07 4:33
lavy28834-Apr-07 4:33 
Questionstatic variables in MFC Pin
iayd4-Apr-07 3:17
iayd4-Apr-07 3:17 
AnswerRe: static variables in MFC Pin
David Crow4-Apr-07 3:32
David Crow4-Apr-07 3:32 

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.