Click here to Skip to main content
15,914,070 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: thank you Pin
Mike Savoie15-Oct-02 9:30
Mike Savoie15-Oct-02 9:30 
Generalhowto get fileinformation Pin
mkrelli15-Oct-02 7:22
mkrelli15-Oct-02 7:22 
GeneralRe: howto get fileinformation Pin
Tomasz Sowinski15-Oct-02 7:43
Tomasz Sowinski15-Oct-02 7:43 
GeneralCComboBox acts like CEdit Pin
john john mackey15-Oct-02 7:14
john john mackey15-Oct-02 7:14 
GeneralRe: CComboBox acts like CEdit Pin
Tomasz Sowinski15-Oct-02 7:23
Tomasz Sowinski15-Oct-02 7:23 
Generalhandlin WM_KILLFOCUS in CWnd-derived Pin
mishgun15-Oct-02 6:23
mishgun15-Oct-02 6:23 
GeneralRe: handlin WM_KILLFOCUS in CWnd-derived Pin
Roger Allen16-Oct-02 2:07
Roger Allen16-Oct-02 2:07 
GeneralLast Thread post for me... Pin
15-Oct-02 6:14
suss15-Oct-02 6:14 
Hello,
I have learned a ton in the past few days.. Having never programmed UI Threads (with the help of articles on Code Project and all of you) I have implemented a UI thread that contains a CSocket for file transfer.. The server works perfect except when I close the server I have a memory leak.. This is how I start the UI Thread and how I close the UI thread.. what am I doing wrong??

Here is the creation inside CMainFrame
////////////////////////////////////////////////////////////////////////
// Create the UI Thread for file transfer
CFtThread* pThread = (CFtThread*)AfxBeginThread(RUNTIME_CLASS(CFtThread),
THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
					
	pThread->m_nPort = 21;
	pThread->ResumeThread();
	pThread->OnStartListening();
// End of Thread
////////////////////////////////////////////////////////////////////////


Here is how I am trying to close the thread.. it's in CMainFrame::OnClose()
void CMainFrame::OnClose() 
{
..... code
CFtThread* pThread = (CFtThread*)AfxGetThread();
pThread->ExitInstance();
..... code

CFrameWnd::OnClose();
}


In my int CFtThread::ExitInstance() I try to close the socket and remove any connected sockets...
int CFtThread::ExitInstance()
{
	m_sSocket.ShutDown(2);
	m_sSocket.Close();
	
	POSITION pos, temp;
	pos = m_pEpList.GetHeadPosition(); // m_pEpList is a CPtrList

	while(!m_pEpList.IsEmpty())
	{
		temp = pos;
		CFtSocket* pSocket = (CFtSocket*)m_pEpList.GetNext(pos);
		pSocket->Close();	
		m_pEpList.RemoveAt(temp);
	}

	return CWinThread::ExitInstance();
}


Any ideas on why I still have a memory leak?

Thanks,
Rob Jones
GeneralRe: Last Thread post for me... Pin
jmkhael15-Oct-02 6:32
jmkhael15-Oct-02 6:32 
GeneralRe: Last Thread post for me... Pin
Anonymous15-Oct-02 6:56
Anonymous15-Oct-02 6:56 
GeneralRe: Last Thread post for me... Pin
Jon Hulatt15-Oct-02 6:42
Jon Hulatt15-Oct-02 6:42 
GeneralRe: Last Thread post for me... Pin
Anonymous15-Oct-02 7:02
Anonymous15-Oct-02 7:02 
GeneralRe: Last Thread post for me... Pin
Jon Hulatt15-Oct-02 21:24
Jon Hulatt15-Oct-02 21:24 
GeneralHere's the memory dump, if it helps.. Pin
Anonymous15-Oct-02 7:29
Anonymous15-Oct-02 7:29 
GeneralRe: Here's the memory dump, if it helps.. Pin
Jon Hulatt15-Oct-02 21:16
Jon Hulatt15-Oct-02 21:16 
GeneralRe: Here's the memory dump, if it helps.. Pin
jhwurmbach15-Oct-02 22:30
jhwurmbach15-Oct-02 22:30 
GeneralRe: Last Thread post for me... Pin
KaЯl16-Oct-02 0:23
KaЯl16-Oct-02 0:23 
GeneralPrint preview and OnClose Pin
-Dy15-Oct-02 4:45
-Dy15-Oct-02 4:45 
GeneralRe: Print preview and OnClose Pin
Tomasz Sowinski15-Oct-02 4:58
Tomasz Sowinski15-Oct-02 4:58 
GeneralRe: Print preview and OnClose Pin
-Dy15-Oct-02 5:31
-Dy15-Oct-02 5:31 
GeneralSCroll bar size Pin
suresh_sathya15-Oct-02 3:30
suresh_sathya15-Oct-02 3:30 
GeneralRe: SCroll bar size Pin
Tomasz Sowinski15-Oct-02 3:41
Tomasz Sowinski15-Oct-02 3:41 
GeneralUse CRecordSet with Access Pin
MyEden15-Oct-02 2:58
MyEden15-Oct-02 2:58 
GeneralRe: Use CRecordSet with Access Pin
Tomasz Sowinski15-Oct-02 3:14
Tomasz Sowinski15-Oct-02 3:14 
GeneralRe: Use CRecordSet with Access Pin
MyEden15-Oct-02 3:14
MyEden15-Oct-02 3:14 

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.