how to create new thread
-
Hi, I need to create new thread if I click on particular button in my MFC application.I have added following code.
AfxBeginThread( CRuntimeClass* pfnThreadProc,LPVOID pParam,
int nPriority = THREAD_PRIORITY_NORMAL,UINT nStackSize = 0,
DWORD dwCreateFlags = 0,LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
UINT CTestcycleDlg::pfnThreadProc(LPVOID pParam )
{
}I am getting errors one of thoes error is
error C2275: 'CRuntimeClass' : illegal use of this type as an expression
I have created user interface thread.Is it correct.Where I need to close thread and how to close -
Hi, I need to create new thread if I click on particular button in my MFC application.I have added following code.
AfxBeginThread( CRuntimeClass* pfnThreadProc,LPVOID pParam,
int nPriority = THREAD_PRIORITY_NORMAL,UINT nStackSize = 0,
DWORD dwCreateFlags = 0,LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
UINT CTestcycleDlg::pfnThreadProc(LPVOID pParam )
{
}I am getting errors one of thoes error is
error C2275: 'CRuntimeClass' : illegal use of this type as an expression
I have created user interface thread.Is it correct.Where I need to close thread and how to closeHaven't you tried CreateThread[^]. But be careful to terminate thread. For that you can see this[^].
Do not trust a computer... Always check what computer is doing regards, Divyang Mithaiwala Software Engineer
-
Haven't you tried CreateThread[^]. But be careful to terminate thread. For that you can see this[^].
Do not trust a computer... Always check what computer is doing regards, Divyang Mithaiwala Software Engineer
-
Hi, I need to create new thread if I click on particular button in my MFC application.I have added following code.
AfxBeginThread( CRuntimeClass* pfnThreadProc,LPVOID pParam,
int nPriority = THREAD_PRIORITY_NORMAL,UINT nStackSize = 0,
DWORD dwCreateFlags = 0,LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
UINT CTestcycleDlg::pfnThreadProc(LPVOID pParam )
{
}I am getting errors one of thoes error is
error C2275: 'CRuntimeClass' : illegal use of this type as an expression
I have created user interface thread.Is it correct.Where I need to close thread and how to closehemlat wrote:
UINT CTestcycleDlg::pfnThreadProc(LPVOID pParam )
Your method which will work as thread & belong to class then it must be define
static
. But is method is not belong to any class then it is no matter to have static.hemlat wrote:
AfxBeginThread( CRuntimeClass* pfnThreadProc,LPVOID pParam,
When you pass pointer/name of method use
CTestcycleDlg::pfnThreadProc
. I hope this will work for your code.
Do not trust a computer... Always check what computer is doing regards, Divyang Mithaiwala Software Engineer
-
You can use
createThread
method.There is no matter of MFC.
Do not trust a computer... Always check what computer is doing regards, Divyang Mithaiwala Software Engineer
-
You can use
createThread
method.There is no matter of MFC.
Do not trust a computer... Always check what computer is doing regards, Divyang Mithaiwala Software Engineer
-
You are correct, you should NOT be using the CreateThread()[^] Win API version if you are using MFC (Again, look at the remarks section of
CWinThread
class to know why). But, if you want that kind of functionality (which you may need with UI threads), you can then create aCMyThread
object and then callCMyThread::CreateThread()
when you want the thread to start execution. (CMyThread
is aCWinThread
derivative.)It is a crappy thing, but it's life -^ Carlo Pallini
-
Hi, I need to create new thread if I click on particular button in my MFC application.I have added following code.
AfxBeginThread( CRuntimeClass* pfnThreadProc,LPVOID pParam,
int nPriority = THREAD_PRIORITY_NORMAL,UINT nStackSize = 0,
DWORD dwCreateFlags = 0,LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
UINT CTestcycleDlg::pfnThreadProc(LPVOID pParam )
{
}I am getting errors one of thoes error is
error C2275: 'CRuntimeClass' : illegal use of this type as an expression
I have created user interface thread.Is it correct.Where I need to close thread and how to closeHere is an UI thread tutorial: UI threads[^]
It is a crappy thing, but it's life -^ Carlo Pallini
-
Hi, I need to create new thread if I click on particular button in my MFC application.I have added following code.
AfxBeginThread( CRuntimeClass* pfnThreadProc,LPVOID pParam,
int nPriority = THREAD_PRIORITY_NORMAL,UINT nStackSize = 0,
DWORD dwCreateFlags = 0,LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
UINT CTestcycleDlg::pfnThreadProc(LPVOID pParam )
{
}I am getting errors one of thoes error is
error C2275: 'CRuntimeClass' : illegal use of this type as an expression
I have created user interface thread.Is it correct.Where I need to close thread and how to closehemlat wrote:
AfxBeginThread( CRuntimeClass* pfnThreadProc,LPVOID pParam, int nPriority = THREAD_PRIORITY_NORMAL,UINT nStackSize = 0, DWORD dwCreateFlags = 0,LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
What is this? Are you trying to call
AfxBeginThread()
, or just duplicate the prototype?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Hi, I need to create new thread if I click on particular button in my MFC application.I have added following code.
AfxBeginThread( CRuntimeClass* pfnThreadProc,LPVOID pParam,
int nPriority = THREAD_PRIORITY_NORMAL,UINT nStackSize = 0,
DWORD dwCreateFlags = 0,LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
UINT CTestcycleDlg::pfnThreadProc(LPVOID pParam )
{
}I am getting errors one of thoes error is
error C2275: 'CRuntimeClass' : illegal use of this type as an expression
I have created user interface thread.Is it correct.Where I need to close thread and how to closehemlat wrote:
UINT CTestcycleDlg::pfnThreadProc(LPVOID pParam )
i think you forget to make function static
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
Rajesh R Subramanian wrote:
Actually, there is. Please read the docs[^]
Good reference
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
hemlat wrote:
AfxBeginThread( CRuntimeClass* pfnThreadProc,LPVOID pParam, int nPriority = THREAD_PRIORITY_NORMAL,UINT nStackSize = 0, DWORD dwCreateFlags = 0,LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL);
What is this? Are you trying to call
AfxBeginThread()
, or just duplicate the prototype?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Actually I dont know how to create thread.I have tried with above code.I am seaching the code for thread creation.
hemlat wrote:
I am seaching the code for thread creation. Quote Selected Text
Still?! Are you kidding me? I gave you link to an excellent UI thread tutorial yesterday. Did you read it or not? Why are you "searching" for code, BTW? You're supposed to write code if you are a programmer of any kind.
It is a crappy thing, but it's life -^ Carlo Pallini
-
hemlat wrote:
I am seaching the code for thread creation. Quote Selected Text
Still?! Are you kidding me? I gave you link to an excellent UI thread tutorial yesterday. Did you read it or not? Why are you "searching" for code, BTW? You're supposed to write code if you are a programmer of any kind.
It is a crappy thing, but it's life -^ Carlo Pallini
-
Thanks for your reply.Just now I have started working.Morning I was busy with some other task.Just I replyed to his message he was asking me what I was doing.I started working on Link which u hv sent.
-
I need to create worker thread.Because I need to put my functionality in thread function. Can you suggest any link which will show how to create worker thread
-
I need to create worker thread.Because I need to put my functionality in thread function. Can you suggest any link which will show how to create worker thread
hemlat wrote:
Can you suggest any link which will show how to create worker thread
Did you even bother to read the article that Rajesh provided? If you had, you would have noticied a link to this. :rolleyes:
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-