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. Need help in Threading in win32

Need help in Threading in win32

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
9 Posts 2 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

    I have listview in the application. In that listview there are so many files I am using those files for encoding/protection process. But by the help of threading . so if a user can do the endcoding proccess as well as protection process and can add in between the running process if he can add more files in the list and also can start that files for the encoding/protection on then they can do. how can i start the threading for that . i have alread done the following things. I have made one class Thread in that class I add the method beginthread. that method call from the starting process of protection. like . void Therad(PVOID param) { Package pkg=(Package)param; pkg.EncodeMediaContent(param1,param2 ); } but i havent got the iead that how these paramter comes ?

    "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

    A 1 Reply Last reply
    0
    • A amitmistry_petlad

      I have listview in the application. In that listview there are so many files I am using those files for encoding/protection process. But by the help of threading . so if a user can do the endcoding proccess as well as protection process and can add in between the running process if he can add more files in the list and also can start that files for the encoding/protection on then they can do. how can i start the threading for that . i have alread done the following things. I have made one class Thread in that class I add the method beginthread. that method call from the starting process of protection. like . void Therad(PVOID param) { Package pkg=(Package)param; pkg.EncodeMediaContent(param1,param2 ); } but i havent got the iead that how these paramter comes ?

      "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

      A Offline
      A Offline
      Arman S
      wrote on last edited by
      #2

      Do not launch threads by beginthread, instead use _beginthreadex. But if you are using MFC, then use AfxBeginThread global function. You should have struct with containing the parameters you want to pass the thread. Then you can pass the struct object and retrieve the parameters from there. See here[^] for more details.

      -- ===== Arman

      A 2 Replies Last reply
      0
      • A Arman S

        Do not launch threads by beginthread, instead use _beginthreadex. But if you are using MFC, then use AfxBeginThread global function. You should have struct with containing the parameters you want to pass the thread. Then you can pass the struct object and retrieve the parameters from there. See here[^] for more details.

        -- ===== Arman

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

        yes i am using win32. Thanks for you help.

        "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

        1 Reply Last reply
        0
        • A Arman S

          Do not launch threads by beginthread, instead use _beginthreadex. But if you are using MFC, then use AfxBeginThread global function. You should have struct with containing the parameters you want to pass the thread. Then you can pass the struct object and retrieve the parameters from there. See here[^] for more details.

          -- ===== Arman

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

          I faced proble with _beginthread(functionname,0,**argumentlist**); what does it mean ? mean i have to write param1,param2,param3 or the argument list is simple integer number. can any body explaine me detail. it is better ,if possible with some code .

          "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

          A 1 Reply Last reply
          0
          • A amitmistry_petlad

            I faced proble with _beginthread(functionname,0,**argumentlist**); what does it mean ? mean i have to write param1,param2,param3 or the argument list is simple integer number. can any body explaine me detail. it is better ,if possible with some code .

            "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

            A Offline
            A Offline
            Arman S
            wrote on last edited by
            #5

            As I said in my previous post, only do use AfxBeginThread in MFC based apps. Otherwise use _beginthreadex and not what you are using now (_beginthread). And I guess you are using MFC because you mentioned about listview control... Anyway, just to be answered; I faced proble with _beginthread(functionname,0,argumentlist); The first param is the controlling function name which should have the following syntax; DWORD MyThread(PVOID *pParam); The second param is the stack size. Pass 0 for defaulting. The third parameter is some address through which you want to pass arguments to MyThread; struct INFO { // assume you want to pass 3 arguments int param1; char param2; SomeClass *pObject; }; INFO *pInfo = new INFO; // initialize pInfo fields AfxBeginThread(MyThread, 0, (PVOID ) pInfo); // start thread // Then inside the controlling function DWORD MyThread(PVOID pParam) { INFO *pInfo = (INFO *) pParam; int p1 = pInfo->param1; char p2 = pInfo->param2; SomeClass *p = pInfo->pObject; // do whatever ... delete pInfo; // do a proper memory release return 0; }

            -- ===== Arman

            A 1 Reply Last reply
            0
            • A Arman S

              As I said in my previous post, only do use AfxBeginThread in MFC based apps. Otherwise use _beginthreadex and not what you are using now (_beginthread). And I guess you are using MFC because you mentioned about listview control... Anyway, just to be answered; I faced proble with _beginthread(functionname,0,argumentlist); The first param is the controlling function name which should have the following syntax; DWORD MyThread(PVOID *pParam); The second param is the stack size. Pass 0 for defaulting. The third parameter is some address through which you want to pass arguments to MyThread; struct INFO { // assume you want to pass 3 arguments int param1; char param2; SomeClass *pObject; }; INFO *pInfo = new INFO; // initialize pInfo fields AfxBeginThread(MyThread, 0, (PVOID ) pInfo); // start thread // Then inside the controlling function DWORD MyThread(PVOID pParam) { INFO *pInfo = (INFO *) pParam; int p1 = pInfo->param1; char p2 = pInfo->param2; SomeClass *p = pInfo->pObject; // do whatever ... delete pInfo; // do a proper memory release return 0; }

              -- ===== Arman

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

              struct argument_list l; l.pszInFile=wInFile; l.pszOutFil=w_Output; l._ProtectSet=_ProtectSet; l.hList=hList; l.Host=HOST; l.hwndEncrypt=hwndEncrypt; l.hWndinoutfiledir=hWndinoutfiledir; l.hwndParent=hDlg; l.InitPackageRequest=sINIT_PACKAGE_RESPONSE; l.Port=PORT; l.ScriptFile=COMMUNICATOR_SCRIPT_FILE_PATH; l.UserID=UserID; UINT Iselected=ListView_GetSelectedCount(hList); for(int i;i error C2664: '_beginthreadex' : cannot convert parameter 6 from 'argument_list *__w64 ' to 'unsigned int *'

              "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

              A 1 Reply Last reply
              0
              • A amitmistry_petlad

                struct argument_list l; l.pszInFile=wInFile; l.pszOutFil=w_Output; l._ProtectSet=_ProtectSet; l.hList=hList; l.Host=HOST; l.hwndEncrypt=hwndEncrypt; l.hWndinoutfiledir=hWndinoutfiledir; l.hwndParent=hDlg; l.InitPackageRequest=sINIT_PACKAGE_RESPONSE; l.Port=PORT; l.ScriptFile=COMMUNICATOR_SCRIPT_FILE_PATH; l.UserID=UserID; UINT Iselected=ListView_GetSelectedCount(hList); for(int i;i error C2664: '_beginthreadex' : cannot convert parameter 6 from 'argument_list *__w64 ' to 'unsigned int *'

                "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

                A Offline
                A Offline
                Arman S
                wrote on last edited by
                #7

                UINT nThreadID; // might be useful later _beginthreadex( NULL, 0, &Thread , &l, 0, &nThreadID);

                -- ===== Arman

                A 2 Replies Last reply
                0
                • A Arman S

                  UINT nThreadID; // might be useful later _beginthreadex( NULL, 0, &Thread , &l, 0, &nThreadID);

                  -- ===== Arman

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

                  thanks arman now i got idea . thanks again.:rose:

                  "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

                  1 Reply Last reply
                  0
                  • A Arman S

                    UINT nThreadID; // might be useful later _beginthreadex( NULL, 0, &Thread , &l, 0, &nThreadID);

                    -- ===== Arman

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

                    Hi!, Ya the application is now ok,But I need your help for continuous proccess how can it possible? Suppose there are five files running in the protection stage. and two three more files are now added in the list and I again give the start command for protection then how these files work with the already running process. I think you can understad the problem.

                    "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

                    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