Click to See Complete Forum and Search --> : HELP: Worker threads and CDaoDatabase (Part 2)


EricNielsen
May 6th, 1999, 01:03 PM
I have an application which runs lengthy database
analysis. A UI dialog collects the analysis parameters,
and runs the analysis after the user clicks "OK".

The application is structured so that the actual
analysis is performed in a worker thread. On clicking
"OK", a worker thread is started. The worker function
dynamically allocates a database object which contains
(among other things) a CDaoDatabase member and several
methods used in the analysis. After allocation, the
the analysis routine is started, it runs to completion,
the database object is deleted, and the worker function
exits. At this point I should be done with the database
entirely.

The problem: When I close the main dialog to shut down
application (this is in the main thread), I get an
exception error in MFCD42D.DLL in AfxDaoTerm(). I know
that there are thread issues with DAO, but as far as I
can tell, I have completely encapsulated my database
access in the worker thread.

An ideas on what I'm doing wrong?

Eric

Peter Hendén
May 25th, 1999, 07:22 PM
There are articles which address these probs:
KB: Q169395 and
"DAO and the Apartment-threading Model"

These and several more can be found in the MSDN library. (or http://msdn.microsoft.com).

You need to build with _UNICODE defined and there are more restrictions. I gave up on DAO because of them.

HTH,
Peter