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

C / C++ / MFC

 
GeneralRe: Terminating a thread from a different thread Pin
Neville Franks28-Sep-04 10:35
Neville Franks28-Sep-04 10:35 
GeneralMessage lost when sending to split windows Pin
mike-o28-Sep-04 6:03
mike-o28-Sep-04 6:03 
GeneralRe: Message lost when sending to split windows Pin
Sujan Christo28-Sep-04 19:40
Sujan Christo28-Sep-04 19:40 
GeneralCustom Shell handler Pin
Jim Crafton28-Sep-04 6:00
Jim Crafton28-Sep-04 6:00 
GeneralRe: Custom Shell handler Pin
David Crow28-Sep-04 9:54
David Crow28-Sep-04 9:54 
QuestionHow to change menu item propeties ? Pin
zakarias28-Sep-04 5:22
zakarias28-Sep-04 5:22 
AnswerRe: How to change menu item propeties ? Pin
Antony M Kancidrowski28-Sep-04 6:10
Antony M Kancidrowski28-Sep-04 6:10 
GeneralTerminating a Thread Pin
sweep12328-Sep-04 4:34
sweep12328-Sep-04 4:34 
I have a memory leak and think I have found it. So my question is whats the best way to terminate this thread.

The final tidy-up section of code is never reached.

The thread reads UDP data packets and updates a database; but on my main program exit routine should I kill this thread? As could be waiting on a read.

while(g_bUDP_Socket_Created)<br />
{<br />
        int len = sizeof(RxBuffer);<br />
        bytesRead = recvfrom (conn_socket, (char *)&RxBuffer,  sizeof(Data), 0, (struct sockaddr *)&from, &length);<br />
	// bytesRead = recv(conn_socket, BufferIn, sizeof(BufferIn), 0);<br />
	// Check for error and terminate the thread if any found<br />
	if (bytesRead == SOCKET_ERROR) <br />
	{<br />
		g_sFormatting.Format("recvfrom() failed: %d\n",WSAGetLastError());<br />
			AfxMessageBox(g_sFormatting);<br />
		WSACleanup();<br />
		return -1;<br />
	}<br />
	::EnterCriticalSection(&g_csRxLock);	// Apply lock<br />
		memcpy(&g_RxData, &RxBuffer, sizeof(Data));<br />
		// Now update the Database with the new data received<br />
		UpdateDataBase();<br />
	::LeaveCriticalSection(&g_csRxLock);	// Release the lock<br />
	// Increment the UDP Packet counter<br />
	g_nUDPCounter++;<br />
}<br />
	// Close the Winsock and tidy up<br />
	closesocket(conn_socket);<br />
	WSACleanup();<br />
// This point never reached !!!!<br />
	return 0;

GeneralRe: Terminating a Thread Pin
Blake Miller28-Sep-04 4:49
Blake Miller28-Sep-04 4:49 
GeneralRe: Terminating a Thread Pin
sweep12328-Sep-04 6:11
sweep12328-Sep-04 6:11 
GeneralRe: Terminating a Thread Pin
Blake Miller28-Sep-04 6:28
Blake Miller28-Sep-04 6:28 
Questiondoc/view ??? Pin
Plons28-Sep-04 4:08
Plons28-Sep-04 4:08 
AnswerRe: doc/view ??? Pin
HENDRIK R28-Sep-04 4:55
HENDRIK R28-Sep-04 4:55 
AnswerRe: doc/view ??? Pin
David Crow28-Sep-04 5:43
David Crow28-Sep-04 5:43 
GeneralHandle of the View Pin
Neelesh K J Jain28-Sep-04 4:06
Neelesh K J Jain28-Sep-04 4:06 
GeneralRe: Handle of the View Pin
David Crow28-Sep-04 5:51
David Crow28-Sep-04 5:51 
GeneralRe: Handle of the View Pin
Sujan Christo28-Sep-04 8:57
Sujan Christo28-Sep-04 8:57 
GeneralPrinting help! Pin
Larsson28-Sep-04 3:37
Larsson28-Sep-04 3:37 
GeneralRe: Printing help! Pin
Andrzej Markowski3-Oct-04 14:23
Andrzej Markowski3-Oct-04 14:23 
GeneralImage Processing Pin
Fonzo28-Sep-04 3:25
Fonzo28-Sep-04 3:25 
GeneralHidden my Application in tag list Pin
Gledston Reis28-Sep-04 3:02
sussGledston Reis28-Sep-04 3:02 
GeneralRe: Hidden my Application in tag list Pin
David Crow28-Sep-04 7:29
David Crow28-Sep-04 7:29 
GeneralRe: Hidden my Application in tag list Pin
PJ Arends28-Sep-04 13:12
professionalPJ Arends28-Sep-04 13:12 
GeneralRe: Hidden my Application in tag list Pin
David Crow29-Sep-04 2:53
David Crow29-Sep-04 2:53 
GeneralRe: Hidden my Application in tag list Pin
Gledston Reis29-Sep-04 8:47
sussGledston Reis29-Sep-04 8:47 

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.