The SARG solution is not safe, and can only works if the thread accesses to static fields only.
If the thread must access to non static member fields, you must add a static wrapper.
In addition, as cited in the documentation, the ThreadCall working is not presently guaranteed when parameters must be passed (the object instance).
Instead use ThreadCreate.
Simple example:
Code: Select all
type sec_integer
dim as integer value
declare sub mt_watchdog
declare static sub mt_watchdog_launcher (byval p as any ptr)
declare constructor
end type
constructor sec_integer
threadcreate(@sec_integer.mt_watchdog_launcher, @this)
end constructor
sub sec_integer.mt_watchdog ()
do
print "IT WORKS!", value
sleep 1
loop until inkey <> ""
end sub
static sub sec_integer.mt_watchdog_launcher (byval p as any ptr)
cptr(sec_integer ptr, p)->mt_watchdog()
end sub
dim as sec_integer test
test.value = 1234
sleep