My thead application gets hang
-
Hello everybody! my thread application gets hang. can anybody help me welcome for sharing the code.
"Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India
-
Hello everybody! my thread application gets hang. can anybody help me welcome for sharing the code.
"Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India
Can you explain more?
Cheers, Suresh
-
Can you explain more?
Cheers, Suresh
sure dear ! actually i have been waiting for anybody's replay.thanks well I have made list view in that list view there are suppose some files. I have started the batch mode protection . I have to use threading for that. how can I do? the code is below.
hwndListbox=hList; //GetDlgItem(hDlg,IDC_LIST4); //change the list view to global LRESULT ListBoxItemCount=ListView_GetItemCount(hwndListbox); int iSelectedFile1=ListView_GetSelectedCount(hwndListbox); int iSelectedFile=SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_SELECTED); if(ListBoxItemCount > 0) { for(int i=0;ihThread=(HANDLE)_beginthreadex(NULL, 0, &Thread ,&l,NULL, 0); } WaitForSingleObject( hThread, INFINITE ); unsigned __stdcall Thread(void* pArguments ) { HRESULT hr; struct argument_list *Lparam= (argument_list *)pArguments ; Package pkg; //::WaitForSingleObject( hThread, INFINITE ); //::waitfor hr=pkg.EncodeMediaContent(Lparam->pszInFile,Lparam->pszOutFil,Lparam->hwndParent,Lpar
-
sure dear ! actually i have been waiting for anybody's replay.thanks well I have made list view in that list view there are suppose some files. I have started the batch mode protection . I have to use threading for that. how can I do? the code is below.
hwndListbox=hList; //GetDlgItem(hDlg,IDC_LIST4); //change the list view to global LRESULT ListBoxItemCount=ListView_GetItemCount(hwndListbox); int iSelectedFile1=ListView_GetSelectedCount(hwndListbox); int iSelectedFile=SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_SELECTED); if(ListBoxItemCount > 0) { for(int i=0;ihThread=(HANDLE)_beginthreadex(NULL, 0, &Thread ,&l,NULL, 0); } WaitForSingleObject( hThread, INFINITE ); unsigned __stdcall Thread(void* pArguments ) { HRESULT hr; struct argument_list *Lparam= (argument_list *)pArguments ; Package pkg; //::WaitForSingleObject( hThread, INFINITE ); //::waitfor hr=pkg.EncodeMediaContent(Lparam->pszInFile,Lparam->pszOutFil,Lparam->hwndParent,Lpar
Why use a separate thread if you are just going to wait for it to finish? If it's hanging then you can break execution in the debugger and examine the call stack(s) to see where it's hanging. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Why use a separate thread if you are just going to wait for it to finish? If it's hanging then you can break execution in the debugger and examine the call stack(s) to see where it's hanging. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
I got your code (email) and right away I noticed your struct argument_list l; variable that you are passing to your thread isn't static or global so it goes out of scope while the thread is running. That's a big problem :) Instead of making it global, maybe allocate the object with new and pass the pointer to the thread. The thread can delete it when it's done with it or the thread can notify the calling thread somehow and let the calling thread delete it - whatever works best for your application. I'll let you know if I find anything else. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
sure dear ! actually i have been waiting for anybody's replay.thanks well I have made list view in that list view there are suppose some files. I have started the batch mode protection . I have to use threading for that. how can I do? the code is below.
hwndListbox=hList; //GetDlgItem(hDlg,IDC_LIST4); //change the list view to global LRESULT ListBoxItemCount=ListView_GetItemCount(hwndListbox); int iSelectedFile1=ListView_GetSelectedCount(hwndListbox); int iSelectedFile=SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_SELECTED); if(ListBoxItemCount > 0) { for(int i=0;ihThread=(HANDLE)_beginthreadex(NULL, 0, &Thread ,&l,NULL, 0); } WaitForSingleObject( hThread, INFINITE ); unsigned __stdcall Thread(void* pArguments ) { HRESULT hr; struct argument_list *Lparam= (argument_list *)pArguments ; Package pkg; //::WaitForSingleObject( hThread, INFINITE ); //::waitfor hr=pkg.EncodeMediaContent(Lparam->pszInFile,Lparam->pszOutFil,Lparam->hwndParent,Lpar