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
User avatar
ignacio
Site Admin
Posts: 8556
Joined: Mon Apr 06, 2015 8:00 pm
Location: Madrid, Spain
Contact:

Asynchronous functions on next Xailer release

Postby ignacio » Sun Sep 01, 2019 1:42 pm



Sample of use:
1 ) With commands

Code: Select all

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:

Code: Select all

   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]
http://www.xailer.com
http://www.xailer.info

Return to “English”