passing param to the thread function
-
the problem is that i have a thread function
UINT threadfun(LPVOID param) { CList list = (CList)param; }
and i want to pass param to this function using AfxBeginThreadAfxBeginThread(threadfun,(WPARAM)m_List);
where "m_List" is from a type defined variabletypedef CTypedPtrList CList;
the compiler generate this error: 1- 'CList' : undeclared identifier 2- syntax error : missing ';' before identifier 'list' 3- 'list' : undeclared identifier i know he can not see this type "CList" inside the function but what is the solution of this , and how can i make it work thnx alot 4 ur time and concern. -
the problem is that i have a thread function
UINT threadfun(LPVOID param) { CList list = (CList)param; }
and i want to pass param to this function using AfxBeginThreadAfxBeginThread(threadfun,(WPARAM)m_List);
where "m_List" is from a type defined variabletypedef CTypedPtrList CList;
the compiler generate this error: 1- 'CList' : undeclared identifier 2- syntax error : missing ';' before identifier 'list' 3- 'list' : undeclared identifier i know he can not see this type "CList" inside the function but what is the solution of this , and how can i make it work thnx alot 4 ur time and concern.Is this file included...
#include <afxtempl.h>
Nibu thomas A Developer Programming tips[^] My site[^]
-
Is this file included...
#include <afxtempl.h>
Nibu thomas A Developer Programming tips[^] My site[^]
yes it is included, but as u know the thread function is not a part of the class so it can't see the headers so it don't know what is CList exactly is problem right ?? i also tried to make the variable static and access it inside the thread function but it come up with an unresolved external error F Y I, this time was working perfeclty in a member function of the class but with the thread function, i don't know the problem
-
yes it is included, but as u know the thread function is not a part of the class so it can't see the headers so it don't know what is CList exactly is problem right ?? i also tried to make the variable static and access it inside the thread function but it come up with an unresolved external error F Y I, this time was working perfeclty in a member function of the class but with the thread function, i don't know the problem
Hi, yes it is included, but as u know the thread function is not a part of the class so it can't see the headers so it don't know what is CList exactly is Make sure that can be parsed by precompiler when header with your thread function is processed. You can even add
#include <afxtempl.h>
statement directly before your thread function declaration, example:#include <afxtempl.h>
void __stdcall YourThreadFunction(LPVOID param)
{
CList list = (CList)param;
}Did you know that your thread function can also be a part of your class?
#include <afxtempl.h>
class tester {
private:
CList m_list;
public:
void TestMyThread() {
CreateThread(...,...,YourThreadFunction,this,...,...)
};
static void YourThreadFunction(LPVOID param)
{
tester *p = (tester*)param;
CList list1 = p->m_list;
};
};Regards
-
the problem is that i have a thread function
UINT threadfun(LPVOID param) { CList list = (CList)param; }
and i want to pass param to this function using AfxBeginThreadAfxBeginThread(threadfun,(WPARAM)m_List);
where "m_List" is from a type defined variabletypedef CTypedPtrList CList;
the compiler generate this error: 1- 'CList' : undeclared identifier 2- syntax error : missing ';' before identifier 'list' 3- 'list' : undeclared identifier i know he can not see this type "CList" inside the function but what is the solution of this , and how can i make it work thnx alot 4 ur time and concern.singersinger wrote:
typedef CTypedPtrList<CPtrList , tagPLAYLISTENTRY*> CList;
CList
is the name of an existing class. Choose another name.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
the problem is that i have a thread function
UINT threadfun(LPVOID param) { CList list = (CList)param; }
and i want to pass param to this function using AfxBeginThreadAfxBeginThread(threadfun,(WPARAM)m_List);
where "m_List" is from a type defined variabletypedef CTypedPtrList CList;
the compiler generate this error: 1- 'CList' : undeclared identifier 2- syntax error : missing ';' before identifier 'list' 3- 'list' : undeclared identifier i know he can not see this type "CList" inside the function but what is the solution of this , and how can i make it work thnx alot 4 ur time and concern.singersinger wrote:
UINT threadfun(LPVOID param) { CList list = (CList)param; }
There are a few problems here. First, CList is an existing type name when you use MFC. Use a different name for that:
typedef CTypedPtrList CMyList;
. Second, CMyList will be a type, not a pointer. Use the reference operator to cast it to get a pointer to it:AfxBeginThread(threadfun, (WPARAM)&m_List);
and the corresponding:UINT threadfun(LPVOID wParam) { CMyList* list = (CMyList*)wParam; ...}
Finally, if your threadfun is declared in another file, make sure it has the afxtempl.h header included.If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
the problem is that i have a thread function
UINT threadfun(LPVOID param) { CList list = (CList)param; }
and i want to pass param to this function using AfxBeginThreadAfxBeginThread(threadfun,(WPARAM)m_List);
where "m_List" is from a type defined variabletypedef CTypedPtrList CList;
the compiler generate this error: 1- 'CList' : undeclared identifier 2- syntax error : missing ';' before identifier 'list' 3- 'list' : undeclared identifier i know he can not see this type "CList" inside the function but what is the solution of this , and how can i make it work thnx alot 4 ur time and concern.maybe i am posting the wrong words, so to keep it simple i have a function that causes the application to wait till it finishes it's work, so normally you would make it a thread function and call it using AfxBeginThread to let the application continue working after calling it am i right in this ?? if i am right, this function uses some member variables that are declared in the class but the thread function can't see the member variables of the class am i right ?? if i am, i want to pass this member variable to the thread function so that it could understand it and work with it "while this varibale not a rgular data type, it is a typedef from a combination of types" can anybody help me with this for any other information do not hesitate to reply thnx alot 4 ur time and concern.