Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. My thead application gets hang

My thead application gets hang

Scheduled Pinned Locked Moved C / C++ / MFC
help
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amitmistry_petlad
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • A amitmistry_petlad

      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

      S Offline
      S Offline
      sthotakura
      wrote on last edited by
      #2

      Can you explain more?

      Cheers, Suresh

      A 1 Reply Last reply
      0
      • S sthotakura

        Can you explain more?

        Cheers, Suresh

        A Offline
        A Offline
        amitmistry_petlad
        wrote on last edited by
        #3

        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
        
        M 2 Replies Last reply
        0
        • A amitmistry_petlad

          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
          
          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          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

          M 1 Reply Last reply
          0
          • M Mark Salsbery

            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

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • A amitmistry_petlad

              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
              
              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              :laugh: I just got an email saying I have responded to myself here[^] That message was meant for you. Mark

              "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups