Difference between revisions of "Core.asyncCall"

From GiderosMobile
m
(added random example :-()
Line 13: Line 13:
 
'''task''': (function) function to run in background<br/>
 
'''task''': (function) function to run in background<br/>
 
'''parameters''': (multiple) multiple parameters to pass to function '''optional'''<br/>
 
'''parameters''': (multiple) multiple parameters to pass to function '''optional'''<br/>
 +
 +
=== Example ===
 +
<source lang="lua">
 +
local function scaleTextsAndBtn()
 +
local tempFontScale=1.02
 +
 +
Core.yield(.2)
 +
txt1_noads:setScale(tempFontScale)
 +
Core.yield(.1)
 +
txt1_noads:setScale(1)
 +
 +
txt2_plusincome:setScale(tempFontScale)
 +
Core.yield(.1)
 +
txt2_plusincome:setScale(1)
 +
 +
Core.yield(.1)
 +
btn_OK:setScale(1.04)
 +
Core.yield(.2)
 +
btn_OK:setScale(1)
 +
end
 +
 +
Core.asyncCall(scaleTextsAndBtn)
 +
</source>
  
 
{{Core}}
 
{{Core}}

Revision as of 21:09, 4 December 2021

Available since: Gideros 2016.06
Class: Core

Description

Launches a function on a separate thread as a background task.

Core.asyncCall(task,parameters)

Background threads are only executed when the main thread is not running.

Parameters

task: (function) function to run in background
parameters: (multiple) multiple parameters to pass to function optional

Example

local function scaleTextsAndBtn()
	local tempFontScale=1.02

	Core.yield(.2)
	txt1_noads:setScale(tempFontScale)
	Core.yield(.1)
	txt1_noads:setScale(1)

	txt2_plusincome:setScale(tempFontScale)
	Core.yield(.1)
	txt2_plusincome:setScale(1)

	Core.yield(.1)
	btn_OK:setScale(1.04)
	Core.yield(.2)
	btn_OK:setScale(1)
end
 
Core.asyncCall(scaleTextsAndBtn)