, thank you for taking an interest
cyruz wrote:can this be considered a reliable method to do multithreading?
That is what it (the library) is designed to facilitate
. In the case of this function (xDllCall
), the library will create a new (real
) thread, which entry point is outside of the interpreter
, from which it will call the desired function passing the desired parameters, and retrieving the return value, and then sync with the script thread. After the script callback has returned, the library will clean up all allocated memory, close all handles and release all objects which aren't used. The library doesn't use any memory allocated by ahk, for any of its async. work. Hence it is reliable in the sense that there is never any conflict with the interpreter. That being said, the user must take responsibility on its end, that is, it has to make sure that whatever it calls and passes, doesn't cause any conflicts and is valid for the duration of the execution.
I was browsing your code repo and found also threadFunc. How does this compare to it?
starts a new ahk pseudo
, just like, eg, settimer and triggering a hotkey does. It is unrelated to this topic, this topic is about executing non-script
code, in real
kczx3 wrote:On a barely related note, I was just looking at ReadFileEx for asynchronous file reading!
You can call that function with the built-in dllcall
. On a related note, you can call xDllCall
from the completion routine (see ReadFileEx)
, if you want to process the read data asynchronously
, for example, you can pass the buffer to strstr
if you want to find a sub string in the file.