Closed feggaa closed 2 years ago
MsgBox appears twice Then the script works great
Main thread and all sub-threads will execute whole script.
So your top-level MsgBox(...)
line will be executed on every new thread spawned.
That is, if we write everything inside the Main it is not re-executed
NMain() is designed to run [entry point] of script and run once in main thread only.
Great, I understand how it works There are just some cramps sometimes Is it possible for it to accept IDispatch pass without NLocal
Is it possible for it to accept IDispatch pass without NLocal
Yes, all IDispatch objects are accepted.
local $o = createObject(...)
; COM / IDispatch interface (C++)
; AutoItObject (C++)
; AutoItObjectInternal (pure AutoIt)
; IE Object, etc
NRun('task', $o)
func task($o)
MsgBox(0, 'Is it an object?', IsObj($o))
endfunc
This library is really cool, I like your idea and I really started including it in my next project
The problem: But I noticed that the script is restarted only once on the first few run
MsgBox appears twice Then the script works great `
NoTrayIcon ; Should add this to prevent tray icon in sub-thread.
include 'N.au3'
; This test spawns a thread on every button click. $File = 1 func task_1($l) MsgBox(0, 'Task 1 (ID: ' & NGetId() & ')', "Test") For $i = 3 to 15 Sleep(1000) ConsoleWrite(@CRLF&' in task_1 -> '& $i) Next endfunc
MsgBox(0,Assign("File",$File+1),'hello file : '&$File)
Func main() local $l = NLocal() $id = NRun('task_1', $l) While 1 Sleep(1000) ConsoleWrite(@CRLF&' in Looper') WEnd EndFunc
NMain('main') `
Update :
After the review, I did not notice very well that the Main Function is not restored Rather, it only implements its output That is, if we write everything inside the Main it is not re-executed