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.

Asynchronous functions on next Xailer release

Xailer English public forum
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9243
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Asynchronous functions on next Xailer release

Mensaje por ignacio »



Sample of use:
1 ) With commands

Código: Seleccionar todo

METHOD ASYNC Btn1Click( oSender ) CLASS TForm1
...
   AWAIT INLINE {||
         FOR nFor := 1 TO 100
            Sleep(10)
            SYNCHRO INLINE {|| ::oPb1:nValue := nFor }
         NEXT
      RETURN "Exit from first serie"
      }

   // lastAwait is a private VAR with the return value of previous Await command

   AWAIT INLINE {||
      SYNCHRO INLINE { ||  Msginfo( lastWait ) }

      RETURN NIL
      }
RETURN NIL
2) OOP version:

Código: Seleccionar todo

   LOCAL oFuture AS CLASS TFuture
   LOCAL oTask AS CLASS TFutureTask
   LOCAL bWork
   LOCAL nFor

   oFuture := TFuture():New()

   bWork := { ||
      FOR nFor := 1 TO 100
         Sleep(30)
         oFuture:AddSynchroTask( {||::oPb3:nValue := nFor } )
      NEXT
      RETURN "Exit from third serie"
   }

   oFuture:OnComplete := {|| Msginfo( oTask:ReturnValue )  }
   oTask := oFuture:AddThreadTask( bWork )

 RETURN Nil
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Responder