How to Create two simultaneously running threads in VC++

sudhavarma's Avatar
Newbie Member
Can anyone of me tell me how to create two threads in vc++, one thread should record the audio from microphone and copy to a buffer and the other should read from the buffer and play. These have to run simultaneously. There and be 10 buffers where the recorded data is copied, one played from a buffer the same can be used to record again.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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.
evileye's Avatar, Join Date: Jan 2007
Contributor
Is this thread supposed to be in PROGRAMMING forums?

Correct me if i am wrong!
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by evileye
Is this thread supposed to be in PROGRAMMING forums?

Correct me if i am wrong!
Moved to MFC-Win32 Forums