This is the OnInitialUpdate() in which i open the serial port and create/start the threads.....

Code:
void CMyserialportView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
	
	m_hCom = ::CreateFile(	"\\\\.\\COM2",		// filename
			GENERIC_READ|GENERIC_WRITE,	// desired access
			0,							// exclusive
			NULL,						// security irrelevant
			OPEN_EXISTING,				// it has to be there
			FILE_FLAG_OVERLAPPED,		// open asynchronous
			NULL);						// template file
	
	if(m_hCom == NULL)
	{
		AfxMessageBox("Failed to open COM port", 0);
		return;
	}

	// Create writer thread
	m_pSerialWriter = (CSerialWriter*)AfxBeginThread(	
		RUNTIME_CLASS(CSerialWriter),	
		THREAD_PRIORITY_NORMAL,			// priority
		0,								// default stack size
		CREATE_SUSPENDED);				// don't run right away

	if(m_pSerialWriter == NULL)
	{
		AfxMessageBox("Could not create writer thread",0);
		return;
	}

	HANDLE m_hShutDown = ::CreateEvent(NULL, TRUE, FALSE, NULL);
	if(m_hShutDown == NULL)
	{
		AfxMessageBox("Could not create shutdown event",0);
		return;
	}

	m_pSerialWriter->m_pParameters = new CSerialParameters(m_hCom, this, m_hShutDown);
	m_pSerialWriter->ResumeThread();

	CString* myS = new CString("010203040506070809A0010203040506070808");
	m_pSerialWriter->PostThreadMessage(UWM_DATA_SEND, (WPARAM)myS, (LPARAM)0);

	// Create reader thread
	AfxBeginThread(ReaderThread, m_pSerialWriter->m_pParameters);

}