Hallo.
I need to know if an UDF function is a thread, then, when it coloses, if the thread surely closes or not.
Thank you very much
Does a function is a thread?
Re: Does a function is a thread?
A function itself is not a thread. It is part of the code that is being executed as part of a thread. For example, you could call a function from the global code or from a hotkey function, and while it's executing that function, it's the same thread as what called it. The thread doesn't close when the called function closes because it never was its own thread. It just returns control back to where it was called from -- that being the global code space, a function, or whatever.
There is only one thread in this code:
There is only one thread in this code:
Code: Select all
#Requires AutoHotkey v2.0
MsgBox 'This is the global code space, which is the main thread.'
MyFunc
MsgBox 'This is still the global code space.'
ExitApp
MyFunc() {
MsgBox 'This is a function, and it is not a separate thread. It did not interrupt the main thread. It is being executed as part of the main thread.'
}
Re: Does a function is a thread?
Interesting, thank you very much.
I red the manual, but I no understanded, with precision,when a thread begins and when the same thread ends.
I red the manual, but I no understanded, with precision,when a thread begins and when the same thread ends.
Re: Does a function is a thread?
Threads
The current thread is defined as the flow of execution invoked by the most recent event; examples include hotkeys, SetTimer subroutines, custom menu items, and GUI events. The current thread can be executing functions within its own subroutine or within other subroutines called by that subroutine.
Source: Threads - Behaviour & Priority | AutoHotkey v2
Re: Does a function is a thread?
I red it, but it explain only some examples: is there a list of all possible cases? Or what is, with precision, an event?
Re: Does a function is a thread?
I agree that the description is vague. I have relied on the specific examples provided and never encountered anything unexpected, different, or additional. Others may be able to provide greater clarity. I do think of these as events, but a function is not an event. An event is something that happens! A hotkey or GUI action is triggered. A timer is started. A menu is displayed. Well, I have no better words....
Re: Does a function is a thread?
Thank you.
Who is online
Users browsing this forum: DavidP and 77 guests