03-20-2006 02:05 PM
03-20-2006 02:21 PM
Hello Tomsaw,
If you can only run one thread in the thread pool, you can be sure it it always the same thread your function runs in.
You can also make sure that your function is running in this thread by getting the thread's ID (CmtGetThreadID).
03-20-2006 03:49 PM
Hello Tomsaw.
The method proposed by Wim S will certainly work, and is likely the most efficient way to solve your problem.
However, if you prefer not to create a new thread pool, and assuming that you have an available thread in the default thread pool, you could try this:
· Call CmtScheduleThreadPoolFunction(), specifying DEFAULT_THREAD_POOL_HANDLE
· In the scheduled function, do your initialization, then call ProcessSystemEvents() in a loop
· Call PostDeferredCallToThread() each time you want to print a report
Of course, this will also work for any thread pool your app creates.
Regards,
Colin.
03-21-2006 01:48 AM