If I run 2 threads+ using same lib and Alias my script crash.
Can someone help me, is there a way to do this?
Example script:
Code: Select all
#Persistent
#SingleInstance, Force
SetBatchLines, -1
test:=CriticalObject()
test.lib_1:=Ahkthread("
(
#Persistent
SetBatchLines, -1
; 1000 lines lib
; exe:=AhkExported()
; addScript(exe.ahkFunction(""get_lib()""), true)
;lib e.g
class lib_test
{
func_test(a) {
return %a%
}
}
)")
test.thread_1:=Ahkthread("
(
#Persistent
SetBatchLines, -1
exe:=AhkExported()
test:=CriticalObject(" (&test) ")
Alias( go_1, test.lib_1.ahkgetvar( ""lib_test"", 1 ) )
Loop, {
Tooltip, % go_1.func_test(""thread_1 | loop: "" . a_index), 0, 50
Sleep, 10
}
)")
test.thread_2:=Ahkthread("
(
#Persistent
SetBatchLines, -1
test:=CriticalObject(" (&test) ")
Alias( go_2, test.lib_1.ahkgetvar( ""lib_test"", 1 ) )
Loop, {
Tooltip, % go_2.func_test(""thread_2 | loop: "" . a_index), 0, 100
Sleep, 10
}
)")
test.thread_3:=Ahkthread("
(
#Persistent
SetBatchLines, -1
test:=CriticalObject(" (&test) ")
Alias( go_3, test.lib_1.ahkgetvar( ""lib_test"", 1 ) )
Loop, {
Tooltip, % go_3.func_test(""thread_3 | loop: "" . a_index), 0, 150
Sleep, 10
}
)")