[AHK_H v2] pass boundFunc to threads? Topic is solved

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

[AHK_H v2] pass boundFunc to threads?

02 Jan 2019, 15:05

i want to make boundFuncs in my main script and use them in thread scripts, but when i try calling them they crash the thread. besides the unmanaged way of passing them by address, see example, i also tried various combinations of CriticalObject(), CriticalSection(), ObjShare(), ThreadObj() all of which either crashed it as well, or didnt work in the first place(objshare - unable to create). are boundfuncs not supported?

Code: Select all

bf := Func("WhoAmI")
ToolTip("& of bf from main: " (&bf), 200, 200) ; same address, so its ok

ahkThread("
(
	#Persistent
	CoordMode("ToolTip")

	ptr_to_bf := A_Args[1]
	ToolTip("& of bf from thread: " ptr_to_bf, 200, 220) ; same address, so its ok
	Object(ptr_to_bf).Call("thread") ; crash
)", &bf "") ; why does this have to be string concatenated?? otherwise thread tooltip shows chinese chars

WhoAmI(entity) {
	MsgBox("msg from " entity)
}

Esc::ExitApp
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: [AHK_H v2] pass boundFunc to threads?  Topic is solved

06 Jan 2019, 18:54

Unfortunately this is not possible due to Thread Local Storage, since AutoHotkey.exe is multi-thread able.
This might be possible in future when dll will be using TLS as well.

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 18 guests