VB6 Event Callbacks

Let's first examine how event callbacks function in a typical Chilkat method call:
VB6 Event Flow

  1. UI Thread → App Subroutine
    The main VB6 UI loop dispatches an event into your code.
  2. App Subroutine → Chilkat DLL
    Your subroutine invokes a Chilkat method; execution enters native code.
  3. Chilkat DLL → Callback
    Chilkat calls back into your VB6 callback routine.
  4. Callback → Chilkat DLL
    Your callback returns; control resumes inside Chilkat.
  5. Chilkat DLL → App Subroutine
    After all callbacks, the Chilkat call completes and returns to your subroutine.
  6. 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

VB6 Event Flow

  1. UI Thread → VB6 Subroutine
    The main VB6 UI loop dispatches an event into your code.
  2. Subroutine → ChilkatTask
    You call an async Chilkat method, get a ChilkatTask, then run it via task.Run().
  3. task.Run() → New Thread
    Chilkat spins up a native background thread to execute the task.
  4. Background Thread → Callbacks
    Events like AbortCheck, PercentDone, or TaskCompleted originate from the background thread.
    ⚠️ VB6 COM objects use a single-threaded apartment (STA). Direct callbacks from a background thread will crash or deadlock.