Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   How to Create two simultaneously running threads in VC++ (http://www.go4expert.com/forums/create-simultaneously-running-threads-t1899/)

sudhavarma 15Nov2006 09:52

How to Create two simultaneously running threads in VC++
 
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 15Nov2006 11:22

Re: How to Create two simultaneously running threads in VC++
 
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 8Jan2007 18:08

Re: How to Create two simultaneously running threads in VC++
 
Is this thread supposed to be in PROGRAMMING forums?

Correct me if i am wrong!

shabbir 8Jan2007 18:22

Re: How to Create two simultaneously running threads in VC++
 
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


All times are GMT +5.5. The time now is 22:57.