Página 1 de 1

Multitasking Doubt

Publicado: Jue Sep 18, 2014 5:30 pm
por emeasoft
Hello Xailers,
I have a doubt about multitasking, how do I Stop and start a thread within the same code block?
eg.:
The thread is already running and I click the following button to stop and start it again;

METHOD ResetClick()
::oThread1:Stop()
IF ::oThread1:nStatus == 0 //nstatus always returns -1, :Quit() produces the same return
::oThread1:Run( @function() ) //if I set this outside the "IF", the program freezes
ENDIF
RETURN NIL

Thanks,
Juliano

Multitasking Doubt

Publicado: Jue Sep 18, 2014 6:41 pm
por jfgimenez
Juliano,
> I have a doubt about multitasking, how do I Stop and start a
> thread within the same code block?
>
> eg.:
>
> The thread is already running and I click the following
> button to stop and start it again;
>
> METHOD ResetClick()
> ::oThread1:Stop() IF ::oThread1:nStatus == 0 //nstatus always
> returns -1,
> :Quit() produces the same return
> ::oThread1:Run( @function() ) //if I set this outside
> the "IF", the program freezes
> ENDIF
> RETURN NIL
take a look at xailersamplesmultithread. There is a sample to start
and stop a thread.
However, a call to stop() or quit() is not syncronous, so, you cannot
call stop() and, in the next line of code start again the thread. You
must ensure that the thread has really stopped, by checking its status.
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info

Multitasking Doubt

Publicado: Jue Sep 18, 2014 7:33 pm
por emeasoft
Thanks Jose!
I already made it work, Start, Stop, Pause, Resume, everything is working fine, the only doubt left is this...
I tried using a DO WHILE nStatus#0 before using the :Run, but it never changes... It only changes after the event (eg.: click) is over.
TIA,
Juliano