Skip to content

Threading.ahk Question #1

@hsayed21

Description

@hsayed21

Hello,

How can I achieve this? I tried it and it didn't work for me, maybe I'm doing something wrong.

Note about join()
if the initial object with function, the function will automatically called without join, I think it's a mistake, the function is supposed to be executed when join is called
thread1 := Thread(function) ; the function will call directly without calling join()

Example 1

LongOperation() {
	Loop 10 {
		Sleep(1000)
		ToolTip("Step " A_Index " of 10")
	}
}

thread1 := Thread(LongOperation)
; thread1 should work in the background while the script continues to run
MsgBox("This message should be shown before the thread completes.")

Example 2

ProcessWithCallback(data) {
	Sleep(2000) ; Simulate work
	return "Processed: " data
}

thread2 := Thread(ProcessWithCallback, "Test Data")
thread2.OnComplete := (*) => MsgBox("Processing completed!")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions