The following code snippet does that
Code:
DWORD CPipeSampleDlg::CreatePipeThread()
{
	DWORD dwThreadId = 0;

	m_hPipeThread = ::CreateThread(0, 0, (LPTHREAD_START_ROUTINE)StartPipeThread, this, CREATE_SUSPENDED, &dwThreadId);
	ASSERT(m_hPipeThread);

	::SetThreadPriority(m_hPipeThread,THREAD_PRIORITY_IDLE);

	if( !m_hPipeEvent )
		m_hPipeEvent = ::CreateEvent( NULL, FALSE, FALSE, _T("StartUpdateDirectoryThread") );
	else
		::ResetEvent(m_hPipeEvent);
	
	::ResumeThread(m_hPipeThread);

	return dwThreadId;
}
This is the code snippet from the following sample Interprocess communication through Named pipes. You can download the sample and see it working as well.