Thread
Description
- Derived from
-
Disposable abstract
INativeHandle
The Thread represents a background thread.
To create and run a background thread, the following steps are necessary:
-
Creates a new instance of Thread.
-
Set the thread main function with ThreadMain.
-
Call the Start method to initialize and run the background thread.
-
Configure the LogOnError and Priority properties at any time during the threads lifetime.
-
Call the Stop method to tell the background thread to terminate gracefully.
-
Call the Join method to actually wait until the thread has terminated.
-
Finally, dispose the thread to free up system resources. Upon disposal, the Stop and Join method will be called.
The Create method can be used as a shortcut for steps 1, 2, 3 and 5.
Public / Methods
Join
Waits until this thread has terminated.
If the thread has already been terminated, the method returns silently.
Start
Starts this thread.
The method creates a new background thread which will execute the Run
method of the given IThreadMain object (see ThreadMain property).
If the thread has already been started, the method silently returns.
Stop
Stops the thread.
The thread will be signalled to stop. It will not have been terminated when this method returns. Use the Join method for waiting for the termination of the thread.
If the thread has already been stopped, the method returns silently.
Public / Attributes
Argument
The argument object to pass to the thread main method.
The argument object may only be set before Start is called.
Defaults to null
.
- See also
Error
The error info of the exception that has occurred in the Run
method of the threads main method (see IThreadMain).
LogOnError
Output a log message when the thread terminates due to an unhandled exception?
Defaults to true
.
ThreadMain
Gets or sets the thread main method.
The thread main method must be set before Start is called.