invokeAsync decorator

Does anyone have an example of using system.util.invokeAsynchronous as a decorator?

goal:

@async
def someVoidFunc(param1,param2):
  print str(param1 + param2)

got it.

def async(func):
	def inner(*args,**kwargs): 
		def async(func=func,args=args,kwargs=kwargs):
			func(*args,**kwargs)
		system.util.invokeAsynchronous(async)
		
	return inner
	
@async
def somefunc(p1,p2):
	print str(p1+p2)
	
print "1"
somefunc(1,1)
print "3"

ref: Update GUI via Asynchronous thread

1 Like