Skip to content

Commit 9bc8c59

Browse files
committed
update threading script to allow passback of data
1 parent 6cdf958 commit 9bc8c59

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Content/Scripts/upythread.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,30 @@
44
#internal, don't call directly
55
def backgroundAction(args=None):
66
#ue.log(args)
7+
78
action = args[0]
9+
actionArgs = None
10+
811
if len(args) >1:
9-
callback = args[1]
12+
actionArgs = args[1]
13+
14+
if len(args) >2:
15+
callback = args[2]
1016

1117
#call the blocking action
12-
result = action()
18+
if actionArgs:
19+
result = action(actionArgs)
20+
else:
21+
result = action()
1322

1423
#return the result if we have a callback
1524
if callback:
16-
if result is not None:
25+
if result:
1726
ue.run_on_gt(callback, result)
1827
else:
1928
ue.run_on_gt(callback)
2029

2130
#run function on a background thread, optional callback when complete on game thread
22-
def run_on_bt(actionfunction, callback=None):
23-
t = Thread(target=backgroundAction, args=([actionfunction, callback],))
31+
def run_on_bt(actionfunction, functionArgs=None, callback=None):
32+
t = Thread(target=backgroundAction, args=([actionfunction, functionArgs, callback],))
2433
t.start()

0 commit comments

Comments
 (0)