Thanks, that's what I did and it is working fine.
vishi
"Stephan Gerhards" wrote in message
news:3e1a8d2d@newsgroups....
> Hello Vishi
>
> I would prefer to use a global variable, check it in the while loop and
> return, when the variable is set.
>
> e.g.
> volatile BOOL bStopSecond = FALSE;
>
> void Wait(double NumOfSeconds)
> {
> bStopSecond = FALSE;
> ...
> while ()
> {
> ...
> if (bStopSecond) return:
> }
> ....
>
> To stop the second thread, you only must set the variable to TRUE.
>
> Stephan
>
>
> "Vishi Anand" schrieb im Newsbeitrag
> news:3e16276d@newsgroups....
> > I have 2 buttons on my main panel. Pressing one, I start a secondary
> thread,
> > using CmtScheduleThreadPoolFunction function. The secondary thread is
just
> > calling Wait, where Wait is:
> >
> > void Wait(double NumOfSeconds)
> > {
> > double t0;
> > double t1;
> >
> > t0 = Timer();
> > t1 = Timer();
> >
> > while ((t1-t0) < NumOfSeconds) {
> > ProcessSystemEvents();
> > t1 = Timer();
> > }
> > }
> >
> > Now when I press the second button on Main GUI, I want to stop this
> > secondary thread. I know I can use global valiables which I can set in
> main
> > thread and check oftne in secondary thread, but I am looking for doing
by
> > sending a message to the secondary thread. So I tried
> > PostDeferredCallToThread funtion, like:
> >
> > PostDeferredCallToThread(QuitSecondaryThreadFunction, 0,
> > Secondary_Thread_Id)
> >
> > and
> >
> > void CVICALLBACK QuitSecondaryThreadFunction(void* pFunctionData)
> > {
> > CmtExitThreadPoolThread(1); <------- is this correct,How do I call it
> from
> > my secondary thread
> > }
> >
> > When I do that, I see that my secondary thread doesn't process this
> message.
> > The secondary thread is calling ProcessSystemEvents while in wait, so it
> > should process the message, isn't it?
> >
> > I am just starting in this so any help is appreciated.
> >
> > vishi
> >
> >
> >
> >
>
>