Thread

Overview

Class for multithreaded code

Location

  • Reference:
    • Elements.dll  .NET, .NET Core 6.0, .NET Standard 2.0
    • elements.jar  Cooper
    • Elements.fx  Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows, ToffeeV2
    • libElements.fx  Toffee
  • Namespace: RemObjects.Elements.RTL
  • Platforms: .NET, .NET Core 6.0, .NET Standard 2.0, Cooper, Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows, Toffee, ToffeeV2
  • Mapped to:
    • Thread  .NET, .NET Core 6.0, .NET Standard 2.0, Cooper
    • Thread  Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows
    • NSThread  Toffee, ToffeeV2

 

constructor

Creates a new thread with the given entrypoint. Does not start it until Start is called.

 

constructor(aEntrypoint: not nullable Action)

 

Thread(Action! aEntrypoint)

 

// Toffee
init(_ aEntrypoint: () -> ())
// ToffeeV2
init(_ aEntrypoint: Block)

 

Thread(Action aEntrypoint)

 

Sub New(aEntrypoint As Action)

Parameters:

  • aEntrypoint:

Abort .NET, .NET Core 6.0, .NET Standard 2.0, Cooper, Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows, ToffeeV2

Triggers an abort in this thread.

 

method Abort

 

void Abort()

 

func Abort()

 

void Abort()

 

Sub Abort()

Abort Abort()  virtual Toffee

 

func Abort(Abort )

Parameters:

  • :

Async

Run this action async.

 

class method Async(aBlock: Action)

 

static void Async(Action aBlock)

 

// Toffee
static func Async(_ aBlock: () -> ())
// ToffeeV2
static func Async(_ aBlock: Block)

 

static void Async(Action aBlock)

 

Shared Sub Async(aBlock As Action)

Parameters:

  • aBlock:

CallStack

Returns the current callstack for this thread.

 

property CallStack: ImmutableList<String> read;

 

ImmutableList<String> CallStack { get; }

 

var CallStack: ImmutableList<String> { get{} }

 

ImmutableList<String> CallStack { __get; }

 

ReadOnly Property CallStack() As ImmutableList<String>

CurrentCallStack

Returns the current callstack.

 

class property CurrentCallStack: not nullable ImmutableList<String> read;

 

class ImmutableList<String>! CurrentCallStack { get; }

 

static var CurrentCallStack: ImmutableList<String> { get{} }

 

class ImmutableList<String> CurrentCallStack { __get; }

 

Shared ReadOnly Property CurrentCallStack() As ImmutableList<String>

CurrentThread

Returns the current thread.

 

class property CurrentThread: Thread read;

 

class Thread CurrentThread { get; }

 

static var CurrentThread: Thread { get{} }

 

class Thread CurrentThread { __get; }

 

Shared ReadOnly Property CurrentThread() As Thread

IsAlive

True if this thread is still running.

 

property IsAlive: Boolean read;

 

Boolean IsAlive { get; }

 

var IsAlive: Boolean { get{} }

 

Boolean IsAlive { __get; }

 

ReadOnly Property IsAlive() As Boolean

Join .NET, .NET Core 6.0, .NET Standard 2.0, Cooper, Toffee, ToffeeV2

Wait for this thread to finish.

 

method Join

 

void Join()

 

func Join()

 

void Join()

 

Sub Join()

Join (Int32) .NET, .NET Core 6.0, .NET Standard 2.0, Cooper, Toffee, ToffeeV2

Wait for this thread to finish (with a given timeout)

 

method Join(Timeout: Int32)

 

void Join(Int32 Timeout)

 

func Join(_ Timeout: Int32)

 

void Join(Integer Timeout)

 

Sub Join(Timeout As Int32)

Parameters:

  • Timeout:

MainThread Toffee, ToffeeV2

Returns the main thread.

 

static var MainThread: Thread { get{} }

Name

Returns the name of this thread.

 

property Name: String read write;

 

String Name { get; set; }

 

var Name: String { get{} set{} }

 

String Name { __get; __set; }

 

Property Name() As String

Priority Cooper, Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows, Toffee, ToffeeV2

Gets/sets the priority of this threa.d

 

property Priority: ThreadPriority read write;

 

ThreadPriority Priority { get; set; }

 

var Priority: ThreadPriority { get{} set{} }

 

ThreadPriority Priority { __get; __set; }

 

Property Priority() As ThreadPriority

Priority .NET, .NET Core 6.0, .NET Standard 2.0

 

property Priority: ThreadPriority read write;

 

ThreadPriority Priority { get; set; }

 

var Priority: ThreadPriority { get{} set{} }

 

Property Priority() As ThreadPriority

Sleep

Sleep for a given msec.

 

class method Sleep(aTimeout: Int32)

 

static void Sleep(Int32 aTimeout)

 

static func Sleep(_ aTimeout: Int32)

 

static void Sleep(Integer aTimeout)

 

Shared Sub Sleep(aTimeout As Int32)

Parameters:

  • aTimeout:

Start .NET, .NET Core 6.0, .NET Standard 2.0, Cooper, Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows, ToffeeV2

Start this thread.

 

method Start

 

void Start()

 

func Start()

 

void Start()

 

Sub Start()

Start Start()  virtual Toffee

 

func Start(Start )

Parameters:

  • :

ThreadId

Returns the thread id.

 

// .NET, .NET Core 6.0, .NET Standard 2.0
property ThreadId: Int64 read;
// Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows
property ThreadId: ThreadID read;

 

// .NET, .NET Core 6.0, .NET Standard 2.0
Int64 ThreadId { get; }
// Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows
ThreadID ThreadId { get; }

 

// .NET, .NET Core 6.0, .NET Standard 2.0
var ThreadId: Int64 { get{} }
// Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows
var ThreadId: ThreadID { get{} }
// Toffee, ToffeeV2
var ThreadId: IntPtr { get{} }

 

Int64 ThreadId { __get; }

 

// .NET, .NET Core 6.0, .NET Standard 2.0
ReadOnly Property ThreadId() As Int64
// Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows
ReadOnly Property ThreadId() As ThreadID

 

CallStack

Returns the current callstack for this thread.

 

property CallStack: ImmutableList<String> read;

 

ImmutableList<String> CallStack { get; }

 

var CallStack: ImmutableList<String> { get{} }

 

ImmutableList<String> CallStack { __get; }

 

ReadOnly Property CallStack() As ImmutableList<String>

IsAlive

True if this thread is still running.

 

property IsAlive: Boolean read;

 

Boolean IsAlive { get; }

 

var IsAlive: Boolean { get{} }

 

Boolean IsAlive { __get; }

 

ReadOnly Property IsAlive() As Boolean

Name

Returns the name of this thread.

 

property Name: String read write;

 

String Name { get; set; }

 

var Name: String { get{} set{} }

 

String Name { __get; __set; }

 

Property Name() As String

Priority Cooper, Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows, Toffee, ToffeeV2

Gets/sets the priority of this threa.d

 

property Priority: ThreadPriority read write;

 

ThreadPriority Priority { get; set; }

 

var Priority: ThreadPriority { get{} set{} }

 

ThreadPriority Priority { __get; __set; }

 

Property Priority() As ThreadPriority

ThreadId

Returns the thread id.

 

// .NET, .NET Core 6.0, .NET Standard 2.0
property ThreadId: Int64 read;
// Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows
property ThreadId: ThreadID read;

 

// .NET, .NET Core 6.0, .NET Standard 2.0
Int64 ThreadId { get; }
// Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows
ThreadID ThreadId { get; }

 

// .NET, .NET Core 6.0, .NET Standard 2.0
var ThreadId: Int64 { get{} }
// Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows
var ThreadId: ThreadID { get{} }
// Toffee, ToffeeV2
var ThreadId: IntPtr { get{} }

 

Int64 ThreadId { __get; }

 

// .NET, .NET Core 6.0, .NET Standard 2.0
ReadOnly Property ThreadId() As Int64
// Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows
ReadOnly Property ThreadId() As ThreadID

CurrentCallStack

Returns the current callstack.

 

class property CurrentCallStack: not nullable ImmutableList<String> read;

 

class ImmutableList<String>! CurrentCallStack { get; }

 

static var CurrentCallStack: ImmutableList<String> { get{} }

 

class ImmutableList<String> CurrentCallStack { __get; }

 

Shared ReadOnly Property CurrentCallStack() As ImmutableList<String>

CurrentThread

Returns the current thread.

 

class property CurrentThread: Thread read;

 

class Thread CurrentThread { get; }

 

static var CurrentThread: Thread { get{} }

 

class Thread CurrentThread { __get; }

 

Shared ReadOnly Property CurrentThread() As Thread

MainThread Toffee, ToffeeV2

Returns the main thread.

 

static var MainThread: Thread { get{} }

Priority .NET, .NET Core 6.0, .NET Standard 2.0

 

property Priority: ThreadPriority read write;

 

ThreadPriority Priority { get; set; }

 

var Priority: ThreadPriority { get{} set{} }

 

Property Priority() As ThreadPriority

 

Async

Run this action async.

 

class method Async(aBlock: Action)

 

static void Async(Action aBlock)

 

// Toffee
static func Async(_ aBlock: () -> ())
// ToffeeV2
static func Async(_ aBlock: Block)

 

static void Async(Action aBlock)

 

Shared Sub Async(aBlock As Action)

Parameters:

  • aBlock:

Sleep

Sleep for a given msec.

 

class method Sleep(aTimeout: Int32)

 

static void Sleep(Int32 aTimeout)

 

static func Sleep(_ aTimeout: Int32)

 

static void Sleep(Integer aTimeout)

 

Shared Sub Sleep(aTimeout As Int32)

Parameters:

  • aTimeout:

 

constructor

Creates a new thread with the given entrypoint. Does not start it until Start is called.

 

constructor(aEntrypoint: not nullable Action)

 

Thread(Action! aEntrypoint)

 

// Toffee
init(_ aEntrypoint: () -> ())
// ToffeeV2
init(_ aEntrypoint: Block)

 

Thread(Action aEntrypoint)

 

Sub New(aEntrypoint As Action)

Parameters:

  • aEntrypoint:

Abort .NET, .NET Core 6.0, .NET Standard 2.0, Cooper, Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows, ToffeeV2

Triggers an abort in this thread.

 

method Abort

 

void Abort()

 

func Abort()

 

void Abort()

 

Sub Abort()

Abort Abort()  virtual Toffee

 

func Abort(Abort )

Parameters:

  • :

Join .NET, .NET Core 6.0, .NET Standard 2.0, Cooper, Toffee, ToffeeV2

Wait for this thread to finish.

 

method Join

 

void Join()

 

func Join()

 

void Join()

 

Sub Join()

Join (Int32) .NET, .NET Core 6.0, .NET Standard 2.0, Cooper, Toffee, ToffeeV2

Wait for this thread to finish (with a given timeout)

 

method Join(Timeout: Int32)

 

void Join(Int32 Timeout)

 

func Join(_ Timeout: Int32)

 

void Join(Integer Timeout)

 

Sub Join(Timeout As Int32)

Parameters:

  • Timeout:

Start .NET, .NET Core 6.0, .NET Standard 2.0, Cooper, Island-Android, Island-iOS, Island-iOS Simulator, Island-Mac Catalyst, Island-macOS, Island-tvOS, Island-tvOS Simulator, Island-Ubuntu, Island-visionOS, Island-visionOS Simulator, Island-watchOS, Island-watchOS Simulator, Island-Windows, ToffeeV2

Start this thread.

 

method Start

 

void Start()

 

func Start()

 

void Start()

 

Sub Start()

Start Start()  virtual Toffee

 

func Start(Start )

Parameters:

  • :