Click here to Skip to main content
15,905,781 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionVC++ and CRystalReport Pin
kasi145-Sep-08 7:39
kasi145-Sep-08 7:39 
AnswerRe: VC++ and CRystalReport Pin
liquid_6-Sep-08 10:48
liquid_6-Sep-08 10:48 
QuestionThreads Pin
bhanu_85095-Sep-08 3:35
bhanu_85095-Sep-08 3:35 
AnswerRe: Threads Pin
David Crow5-Sep-08 3:53
David Crow5-Sep-08 3:53 
AnswerRe: Threads Pin
JudyL_MD5-Sep-08 4:38
JudyL_MD5-Sep-08 4:38 
GeneralRe: Threads Pin
bhanu_85096-Sep-08 0:12
bhanu_85096-Sep-08 0:12 
GeneralRe: Threads Pin
JudyL_MD6-Sep-08 2:46
JudyL_MD6-Sep-08 2:46 
AnswerRe: Threads Pin
Roger Stoltz5-Sep-08 4:42
Roger Stoltz5-Sep-08 4:42 
In addition to David's and JudyL_FL's replies...

bhanu_8509 wrote:
OnCancel();//Here only I got error sometime


I'm surprised you even get that far...
You probably have more than one thread started so the first one is able to suspend the second and continue, or something like that.
You're calling CloseRecord() inside the context of your thread and the first thing you do is suspend the thread. WTF | :WTF:
The thread stops its execution right there and cannot continue if the handle provided is the one of the thread and it looks like you believe it is.

If you manage to get further you kill the thread inside the context of your thread by calling TerminateThread(), which is always a bad call. OMG | :OMG:

And so on...

bhanu_8509 wrote:
while(::WaitForSingleObject(pTSRecording->file_rec,0)==WAIT_TIMEOUT)


This doesn't make any sense at all. This assumes the pTSRecording->file_rec is a valid handle, otherwise you'll get WAIT_FAILED as return value and exit the while-loop.
If it is a valid handle you check whether the handle is in a signalled state and if it isn't you continue immediately. It would be the same to have while(bContinue) instead, where bContinue would be a volatile declared boolean set to false when the thread should stop.

Think real hard whether you need a worker thread at all.
Consider overlapped I/O.
If you still think you need a secondary thread, read this[^].


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


QuestionHow can Extract String ? Pin
Le@rner5-Sep-08 2:54
Le@rner5-Sep-08 2:54 
AnswerRe: How can Extract String ? Pin
_AnsHUMAN_ 5-Sep-08 2:57
_AnsHUMAN_ 5-Sep-08 2:57 
GeneralRe: How can Extract String ? Pin
toxcct5-Sep-08 3:07
toxcct5-Sep-08 3:07 
GeneralRe: How can Extract String ? Pin
_AnsHUMAN_ 5-Sep-08 3:20
_AnsHUMAN_ 5-Sep-08 3:20 
GeneralRe: How can Extract String ? Pin
toxcct5-Sep-08 3:37
toxcct5-Sep-08 3:37 
AnswerRe: How can Extract String ? Pin
Michael Dunn5-Sep-08 8:24
sitebuilderMichael Dunn5-Sep-08 8:24 
GeneralRe: How can Extract String ? Pin
Jerry Jeremiah7-Sep-08 11:21
Jerry Jeremiah7-Sep-08 11:21 
Questionuuid operator Pin
George_George5-Sep-08 2:15
George_George5-Sep-08 2:15 
AnswerRe: uuid operator Pin
_AnsHUMAN_ 5-Sep-08 2:56
_AnsHUMAN_ 5-Sep-08 2:56 
GeneralRe: uuid operator Pin
George_George7-Sep-08 17:23
George_George7-Sep-08 17:23 
AnswerRe: uuid operator Pin
cmk5-Sep-08 3:54
cmk5-Sep-08 3:54 
GeneralRe: uuid operator Pin
George_George7-Sep-08 17:20
George_George7-Sep-08 17:20 
QuestionA C++ Question Pin
False Chicken5-Sep-08 2:13
False Chicken5-Sep-08 2:13 
AnswerRe: A C++ Question Pin
Nibu babu thomas5-Sep-08 2:15
Nibu babu thomas5-Sep-08 2:15 
AnswerRe: A C++ Question Pin
toxcct5-Sep-08 3:10
toxcct5-Sep-08 3:10 
QuestionApplication crashes on calling settimer from a thread function Pin
manoharbalu5-Sep-08 2:05
manoharbalu5-Sep-08 2:05 
AnswerRe: Application crashes on calling settimer from a thread function Pin
Roger Stoltz5-Sep-08 2:57
Roger Stoltz5-Sep-08 2:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.