When a client handle is created, it is associated with the thread
that created it. If another thread attempts to use the handle, the
function will fail because that thread does not own the handle. This
prevents other threads from interfering with an operation being
performed by the owner thread. The LlmAttachThread function
changes the thread that owns the client handle. This is useful when
one thread creates the client session and then passes it to a worker
thread for processing. The function returns the thread ID of the
previous owner, which can be saved and used later to restore ownership
of the handle.
This function should normally be called by the new owner thread
immediately after it has been created. If the worker thread does not
release the handle itself, ownership should be restored to the original
thread before the worker thread terminates. Do not use LlmAttachThread
to forcibly take ownership of a handle from another thread while a
blocking operation is in progress. The handle should only be transferred
when no other thread is actively using it.
The dwThreadId parameter is assumed to be a valid thread ID. This
function does not verify that the specified thread exists. Specifying an
invalid thread ID will orphan the handle until LlmUninitialize is
called.