Basically what I have is a multi-threading issue here. I have created a CDatabase class to wrap CDAODatabase. All it does it make access to the fields in the recordsets and some general database stuff easier.
In this program I have a base class called CSystem. It makes a CDatabase object (MyDatabase) and does some database stuff when it initalizes. I also have a class called CSubSystem that inherets CSystem. It also uses this same object (MyDatabase) for it's database work. Part of it's work is procssing a queue on a regular interval. To do this, I use AfxBeginThread to start a new thread which uses SetWaitableTimer to make a timer. The timer uses a static callback function in the same class which calls a non-static memeber function using a static_cast. This is where my problem arrises. The function called from this callback uses MyDatabase and always fails. It works perfectly when called from the main program but will always fail when called from this thread. I have tried using critical sections but they don't seem to work. I'm not sure if I was using them right or not. I'll post some of my code in a minute. Please help. Thanks.