Hi,
I am new to multithreading. I have made a dll using shared dll using MFC program using a tutorial, after it I changed its settings to statically linked so i can used to call its functions in a multithread. Now when I am calling this dll functions from anbother project I am getting an error, the first thread stops working at soon as the second thread is called upon. My functions and thread definitions are as follows, I have compiled and copy the updated version of the dll file in my new project.
CWinThread *m_thread;
CWinThread *m_thread1;
CdecoderD3D9App *decoder_object_1 = new CdecoderD3D9App(460, 1);
m_thread = AfxBeginThread(MainTread, decoder_object_1);
CdecoderD3D9App *decoder_object_2 = new CdecoderD3D9App(460, 2);
m_thread1 = AfxBeginThread(MainTread1, decoder_object_2);
My functions are as follows for both of the threads,
UINT Ctesting_projectDlg::MainTread(LPVOID pParam)
{
clock_t t1, t2;
t1 = clock();
CdecoderD3D9App *decoder_object_1 = (CdecoderD3D9App *)pParam;
char *video_source = "my_movie.mp4";
decoder_object_1->InitInstance();
decoder_object_1->run_program(video_source);
t2 = clock();
float diff = (((float)t2 - (float)t1) / 1000000.0F ) * 10;
return 0;
}
UINT Ctesting_projectDlg::MainTread1(LPVOID pParam)
{
clock_t t1, t2;
t1 = clock();
CdecoderD3D9App *decoder_object_3 = (CdecoderD3D9App *)pParam;
char *video_source = "my_movie.m2v";
decoder_object_3->InitInstance();
decoder_object_3->run_program(video_source);
t2 = clock();
float diff = (((float)t2 - (float)t1) / 1000000.0F ) * 10;
return 0;
}
Now when I am calling this function the second threads kind of exit the first thread as soon as it is called. Does that mean i have to make a new dll project with statically linked items or any other problem ?
Also the dll class is basically a modified version of DecoderD3D9 CUDA example, in which CWinApp inheritance is removed also so now it is just a simple independant class.
My dll file properties are as:
Configuration Type -> Dynamic Library(.dll)
Use of MFC -> Use MFC in a static library
Character set -> Use Multi-Byte Character Set