Application.CurrentThread

From Xojo Documentation

Read-Only Property (As Thread )
ThreadValue = aApplication.CurrentThread

Supported for all project types and targets.

Obtains the currently running Thread.

Notes

If the current Thread is the main thread (the thread that is used internally to run the application and its UI), CurrentThread returns Nil.

Sample Code

This code gets the ID of the currently running thread, which should be the main thread.

Var t As Thread = App.CurrentThread
If t <> Nil Then
MessageBox("The Thread ID is " + t.ThreadID.ToString)
Else
MessageBox("The thread is the main thread")
End If