VB6 Event Callbacks
Let's first examine how event callbacks function in a typical Chilkat method call:
-
UI Thread → App Subroutine
The main VB6 UI loop dispatches an event into your code. -
App Subroutine → Chilkat DLL
Your subroutine invokes a Chilkat method; execution enters native code. -
Chilkat DLL → Callback
Chilkat calls back into your VB6 callback routine. -
Callback → Chilkat DLL
Your callback returns; control resumes inside Chilkat. -
Chilkat DLL → App Subroutine
After all callbacks, the Chilkat call completes and returns to your subroutine. -
App Subroutine → UI Thread
Your subroutine returns; the UI loop regains control.
If your subroutine blocks too long, the UI loop can’t update—and the interface appears frozen.
Asynchronous VB6 & Chilkat Flow
-
UI Thread → VB6 Subroutine
The main VB6 UI loop dispatches an event into your code. -
Subroutine → ChilkatTask
You call an async Chilkat method, get aChilkatTask
, then run it viatask.Run()
. -
task.Run() → New Thread
Chilkat spins up a native background thread to execute the task. -
Background Thread → Callbacks
Events likeAbortCheck
,PercentDone
, orTaskCompleted
originate from the background thread.
⚠️ VB6 COM objects use a single-threaded apartment (STA). Direct callbacks from a background thread will crash or deadlock.