Sample code for 30+ languages & platforms
Android™

VB6 Finalize Thread Pool on Program Exit (or Crash)

See more Async Examples

VB6 programs must call FinalizeThreadPool on exit if using any Async methods.

If your code is calling asynchronous Chilkat methods (i.e. methods having names ending with "Async"), then it is necessary to call FinalizeThreadPool when your program is about to exit. The VB6 IDE will crash unless all background threads are cleanly terminated.

Chilkat Android™ Downloads

Android™
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Asynchronous Chilkat methods are run in background threads managed
    // by a thread pool manager thread, which is also a background thread.
    // Prior to exiting, it is required in VB6 to ensure all asynchronous methods
    // have completed or are aborted/cancelled, and that the thread pool manager
    // thread is also shutdown.  
    // 
    // The FinalizeThreadPool method should be called just before the application exits
    // to ensure all background threads, including the thread pool manager thread, are
    // cleanly shutdown.

    // This is how to do it:
    CkGlobal glob = new CkGlobal();
    glob.FinalizeThreadPool();

  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}