Killing a thread

I have created a thread using the CBL_CREATE_THREAD routine. However, when I attempt to kill the thread using CBL_THREAD_KILL it does not kill the thread. The thread remains running. My thread is defined as follows

and my call statement is
           Move Return-Code To Thread-Return-Code.

The return code I get is
1009 Invalid parameter passed into a multi-threading library routine. A parameter has been detected that is not within the valid range, or that is inconsistent with the library routine.

Also in visual studio intellisense it says can not find method CBL_THREAD_KILL with this signature. Will create dynamic call.

What am I doing wrong?


  • Verified Answer

    Unfortunately I think the answer is that you're not doing anything wrong.  This is caused by a bug in our compiler, though coincidentally it's a bug that I just fixed.  This will work correctly in the 2.2 Update 1 version of the product.

    As a work-around, try adding a variable of type System.IntPtr, and coding as follows:

          01  THREAD-StatusBar-Routine  USAGE IS THREAD-POINTER.

          01  IntPtr type System.IntPtr.


           set IntPtr to Thread-StatusBar-Routine as type System.IntPtr


  • Thanks That worked to kill the thread. Is there a way to send a message to a thread so that it can exit itself rather then just killing it?

  • Most thread communication can be handled using one of the synchronization primitives like a mutex, event, semaphore, monitor, etc.

    You could also set a flag variable in the main thread in shared storage that the thread could then check to see if it should exit or not.