Multithreading With List & Label

Valid from List & Label 15

List & Label can be used from multiple threads. This enables the distribution of large print jobs on multiple different processors / cores. Internally, this is used for the designer preview or drill down reporting.

If you plan to use List & Label in a multithreaded environment, keep the following issues in mind:

  1. Make sure that each List & Label job (resp. a component instance) is only used within a single thread, i.e. the creation, usage and destruction of the job/component needs to be done from the same thread. If you want to use multiple printing threads, each of these threads needs to open and close it’s own job. Background: Windows GDI resources like window handles or printer device contexts cannot be used across different threads.

  2. Make sure to open a job/create a component instance in your application before starting the first print thread and do not close this job before all threads are terminated. Typically, this will be done in your application’s start-up and shutdown code. Background: the first job creates a couple of helper objects that need to be destroyed in the same job. Also, this can increase the performance remarkably as it avoids steady loading and unloading of DLLs.
    Note: List & Label can work independent of printer drivers from version 27 on (mostly in web applications etc.) and the printerless mode can be activated for this - see also No More Printer Driver Dependency: The New Printerless Mode in List & Label 27.
    For this, the option LL_OPTION_PRINTERLESS for API usage or the Printerless property of the components in the first object/protection job must be set. Mixing enabled and disabled printerless mode in the jobs/objects used in the application is not supported and may result in unexpected behavior.

  3. Threads that open the designer need to use the Single Threaded Apartment (STA) concurrency model. This means you cannot use .NET worker threads from the thread pool for this task, as they are initialized to use the Multi Threaded Apartment (MTA) concurrency model. Background: List & Label needs to call OleInitialize() for drag & drop support within the designer, which requires the current apartment to be STA to succeed.

IDKBTE000799 KBTE000799