Skip to content

get_current_hthread_idGetCurrentHthreadIdGetCurrentHthreadIdget_current_hthread_idget_current_hthread_id🔗

Short description🔗

get_current_hthread_idGetCurrentHthreadIdGetCurrentHthreadIdget_current_hthread_idget_current_hthread_id — Return the HALCON thread ID of the current thread.

Signature🔗

get_current_hthread_id( out integer HThreadID )void GetCurrentHthreadId( HTuple* HThreadID )static void HOperatorSet.GetCurrentHthreadId( out HTuple HThreadID )def get_current_hthread_id( ) -> int

Herror get_current_hthread_id( Hlong* HThreadID )

Herror T_get_current_hthread_id( Htuple* HThreadID )

static Hlong HSystem::GetCurrentHthreadId( )

static int HSystem.GetCurrentHthreadId( )

Description🔗

get_current_hthread_idGetCurrentHthreadId returns a thread ID that represents the currently running thread in HThreadIDHThreadIDhthread_id. This ID is identical to the windows thread ID or the POSIX thread ID on UNIX platforms and is also returned by the par_start operation of the HDevEngine. It can later be used to interrupt operators that are executed in this thread using interrupt_operatorInterruptOperator.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

HThreadIDHThreadIDhthread_id (output_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

ID representing the current thread.

Example🔗

(HDevelop)

global tuple HThreadID
get_current_hthread_id (HThreadID)
* call some slow operator...

* In a different thread
wait_seconds(2)
* Interrupt the long-running operator in the other thread
interrupt_operator (HThreadID, 'break')

Result🔗

If the current thread can be determined, get_current_hthread_idGetCurrentHthreadId returns 2 (H_MSG_TRUE). Otherwise an exception is raised.

Combinations with other operators🔗

Combinations

Possible successors

interrupt_operatorInterruptOperator

See also

interrupt_operatorInterruptOperator, set_operator_timeoutSetOperatorTimeout

Module🔗

Foundation