Need help in Threading in win32
-
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
-
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
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
-
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
yes i am using win32. Thanks for you help.
"Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India
-
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
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
-
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
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
-
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
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
-
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
-
UINT nThreadID; // might be useful later _beginthreadex( NULL, 0, &Thread , &l, 0, &nThreadID);
-- ===== Arman
thanks arman now i got idea . thanks again.:rose:
"Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India
-
UINT nThreadID; // might be useful later _beginthreadex( NULL, 0, &Thread , &l, 0, &nThreadID);
-- ===== Arman
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