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
Responder
Avatar de Usuario
emeasoft
Mensajes: 1088
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

Multitasking Doubt

Mensaje 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
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5706
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Multitasking Doubt

Mensaje 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
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
emeasoft
Mensajes: 1088
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

Multitasking Doubt

Mensaje 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
Responder