Threads in the Win32 API

DB Library for C

DB Library for C

Threads in the Win32 API

The multithreaded process structure of the Microsoft® Win32® API opens up powerful and elegant solutions to high-end applications. Each thread within a process has its own stack and computer state. On multiprocessor systems with the Microsoft Windows NT® 4.0 operating system, multiple threads can execute at the same time but on different processors. Applications that need to perform intensive processing, I/O, and so on, can do this in the background using threads and still offer a responsive user interface.

Using DB-Library in a Threaded Application

Here are a few tips to be aware of when creating a threaded DB-Library application:

  • Make sure you call the dbinit and dbexit functions only one time on your application.

  • Make sure to use per process error and message handling.

  • If you use global error and message handlers, you may need to synchronize access in your error and message handler routines.

  • Make sure to call dbsetmaxprocs if you are going to have more than 25 connections open.

  • Make sure you are compiling/linking with the multithreaded C/C++ run-time libraries. By default, a Microsoft® Visual C/C++® project is linked with the single threaded run-time libraries.

  • If you use the same LOGINREC to open multiple connections, access to the LOGINREC must be serialized.

See Also