Thread
-
susanne1 wrote:
::WaitForSingleObject(m_SEl_Start_Event, 0);
What is the purpose of the above call? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hallo, I have the following problem with the Thread: I create the Thread first as SUSPENDED, but it does not start at the expectetd time. First the Program calls this function: ThreadStart(); /////////////////////////////// ThreadStart() { if (m_pSelThread != NULL) { if (::WaitForSingleObject(m_pSelThread->m_hThread, 0) != WAIT_OBJECT_0) return; delete m_pSelThread; m_pSelThread = NULL; } ::WaitForSingleObject(m_SEl_Start_Event, 0); m_SEl_Start_Event.SetEvent (); // CEvent Object CWinThread* m_pSelThread = AfxBeginThread(ThreadFunktion, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); m_pSelThread->m_bAutoDelete = FALSE; m_pSelThread->ResumeThread(); } UINT ThreadFunktion ( LPVOID param ) { if (param == NULL) return -1; DoSomeThing(); return 0; } The Thread does not come to the UINT ThreadFunktion(LPVOID param). Any help would be appriciated.
Can't you just start the thread and wait for the event to happen within the thread before executing code? What's all this mess about? Why are you setting the
m_bAutoDelete
member to false? I see you may delete it manually, but *what* is the purpose of it?It is a crappy thing, but it's life -^ Carlo Pallini
-
Can't you just start the thread and wait for the event to happen within the thread before executing code? What's all this mess about? Why are you setting the
m_bAutoDelete
member to false? I see you may delete it manually, but *what* is the purpose of it?It is a crappy thing, but it's life -^ Carlo Pallini
-
That doesn't make sense. Anyway I made a test on my system: Without hiding the class member variable, the thread starts happily. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
the thread mus t be created but not start immediately, autodelte false to tell him not to delet himself.
So, why should it not start immediately? Can't you just start it immediately, but not execute any code until the interested event happens? I asked for the reason behind your approach. I did not ask you what
m_bAutoDelete
is for. Tell me why do *you* want the thread not to delete itself.It is a crappy thing, but it's life -^ Carlo Pallini
-
Can't you just start the thread and wait for the event to happen within the thread before executing code? What's all this mess about? Why are you setting the
m_bAutoDelete
member to false? I see you may delete it manually, but *what* is the purpose of it?It is a crappy thing, but it's life -^ Carlo Pallini
Rajesh R Subramanian wrote:
Why are you setting the m_bAutoDelete member to false? I see you may delete it manually, but *what* is the purpose of it?
Well you may want to do that, I mean that's nothing wrong in doing it (and that's the reason for delaying the thread start). :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Rajesh R Subramanian wrote:
Why are you setting the m_bAutoDelete member to false? I see you may delete it manually, but *what* is the purpose of it?
Well you may want to do that, I mean that's nothing wrong in doing it (and that's the reason for delaying the thread start). :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]No, I asked why did he want to delete it manually (as opposed to leave it die in its way). There could be valid reasons, I wanted to know the OP's reason. :)
It is a crappy thing, but it's life -^ Carlo Pallini
-
No, I asked why did he want to delete it manually (as opposed to leave it die in its way). There could be valid reasons, I wanted to know the OP's reason. :)
It is a crappy thing, but it's life -^ Carlo Pallini
You're right: there could be valid reasons, anyway you're very (and, of course, politely) curious about her reason. :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
You're right: there could be valid reasons, anyway you're very (and, of course, politely) curious about her reason. :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Of course, politeness is guaranteed (or 100% money back), after Mr. Maunder's new commandment. :)
It is a crappy thing, but it's life -^ Carlo Pallini
-
Of course, politeness is guaranteed (or 100% money back), after Mr. Maunder's new commandment. :)
It is a crappy thing, but it's life -^ Carlo Pallini
:-D BTW there's a polite way to advice someone to stop using threads? :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Wednesday, August 12, 2009 10:59 AM