|
Not with C++. Now if you were interested in some Windows API, there probably is. What did you have in mind?
"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 just tried to call Sleep(1000) in a thread function
But when i tried to
Unit threadFun(LPVOID lparam)
{
while(1)
{
Sleep(1000); // When tried to give break point over here appliacation gets terminates
............
}
}
Can any one give me solution to this
Thanks
|
|
|
|
|
VVVimal wrote: Can any one give me solution to this
Remove the call to Sleep() . It's almost always unnecessary and usually indicates a design flaw.
"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
|
|
|
|
|
But i need a Sleep() function over there.
Because i need a function to be get called every 1000 milliseconds
|
|
|
|
|
VVVimal wrote: Because i need a function to be get called every 1000 milliseconds
Then use SetTimer(1000) .
"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
|
|
|
|
|
Remember that Windows is not a real-time system, your function might or might not be called at every 1000 milliseconds, depending on what's happening on the OS.
This signature was proudly tested on animals.
|
|
|
|
|
VVVimal wrote: Unit threadFun(LPVOID lparam)
{
while(1)
{
Sleep(1000); // When tried to give break point over here appliacation gets terminates
............
}
}
I don't see why should the application "terminate" with this piece of code. (It might have probably helped us if you had given the remaining code within the thread function to see if anything is wrong)
With more than one thread running, may be the issue is somewhere else? Besides that, like David said, remove the unnecessary Sleep call and replace it with something that makes sense of some sort.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
does the application terminate or does it hang?
i would thing that statement would cause the app to hang... continuous loop with a defined wait time.. is that 1000 seconds or milliseconds it's library specific..??
David
|
|
|
|
|
David, you again replied to me instead of the OP. You should click reply on the specific message that you want to reply to.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
my questions are buried below..
David
|
|
|
|
|
I use Sleep() all the time in threaded code, there's no reason it should cause the termination in and of itself.
However, the thread code you show runs in the context of a larger program, notably the main thread which created the thread you show. What is that thread doing? If it exits, it will take the created thread down with it.
Make sure the main code is waiting for this thread to terminate before it does.
|
|
|
|
|
VVVimal wrote: When tried to give break point over here appliacation gets terminates
do you mean, it is getting terminated when you try to debug?
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
I just added
WatiForSingleObject(threadHandle,INFINITE)
now working fine. Can any one tell why does it so
|
|
|
|
|
My answer above told you exactly why WaitForSingleObject() solved the problem
However, the thread code you show runs in the context of a larger program, notably the main thread which created the thread you show. What is that thread doing? If it exits, it will take the created thread down with it.
|
|
|
|
|
Hi All
How can i read *.xlsx format?I am able to read *.xls format.Plz help me to read *.xlsx format.
|
|
|
|
|
MsmVc wrote: How can i read *.xlsx format?
Isn't it just an XML-type file? Regardless, just use Excel Automation and let Excel handle the details for you.
"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
|
|
|
|
|
thanks for reply but it is pure *.xlsx file and can i read *.xlsx file as a XML.
Plz help me
|
|
|
|
|
|
Hi,
I want to learn ATL. and I dont know any thing about ATL programming. Please send URLs for downloding any free PDF's, and please sujjest me the approach for learnig ATL.
Thnaks In Advance.
sampath-padamatinti
|
|
|
|
|
sampath-padamatinti wrote: I want to learn ATL
It is a demanding aim expecially when you miss the right forum [^].
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]
|
|
|
|
|
sampath-padamatinti wrote: please sujjest me the approach for learnig ATL.
A wise approach would be to locate the beginner level articles on ATL here at CP and start reading those.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I want to set background color of menu and submenu in dialog based application in vc++,mfc
|
|
|
|
|
|
How to display context menu on rightbutton click of mouse in richedit textbox control in vc++.In my application it will display context menu on dialog box on rightbutton click of mouse.but i want to show it on richedit tcontrol textbox in vc++,mfc
|
|
|
|