In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Multitasking Doubt

Xailer professional forum in English
User avatar
emeasoft
Posts: 1062
Joined: Wed Apr 01, 2009 4:12 pm
Location: emeasoft
Contact:

Multitasking Doubt

Postby emeasoft » Thu Sep 18, 2014 5:30 pm

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
User avatar
jfgimenez
Site Admin
Posts: 5620
Joined: Mon Apr 06, 2015 8:48 pm
Contact:

Multitasking Doubt

Postby jfgimenez » Thu Sep 18, 2014 6:41 pm

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
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
User avatar
emeasoft
Posts: 1062
Joined: Wed Apr 01, 2009 4:12 pm
Location: emeasoft
Contact:

Multitasking Doubt

Postby emeasoft » Thu Sep 18, 2014 7:33 pm

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

Return to “English”