Hi, all

I am trying write a dll which will have two thread A and B.
I want to initalize A and B when DLL_PROCESS_ATTACH, to terminate A and B
when DLL_PROCESS_DETACH.
When initalizing, A create thread B, and wait B finish.
When terminating, A notify B, and wait B finish too.

Thanks,
Kai

Re: how to initialize and terminate multithread in dllmain by Nick

Nick
Sun Sep 07 12:55:55 CDT 2003

You can create a thread in DllMain, but you cannot wait for it to begin
executing (among other DllMain restrictions). Follow the suggestions in
the MSDN page on DllMain and put all complex init/uninit into separate
functions invoked at other times.

Kai wrote:

> Hi, all
>
> I am trying write a dll which will have two thread A and B.
> I want to initalize A and B when DLL_PROCESS_ATTACH, to terminate A and B
> when DLL_PROCESS_DETACH.
> When initalizing, A create thread B, and wait B finish.
> When terminating, A notify B, and wait B finish too.
>
> Thanks,
> Kai
>
>
>

--
Nick Ryan (MVP for DDK)


Re: how to initialize and terminate multithread in dllmain by Kai

Kai
Mon Sep 08 22:37:28 CDT 2003

Thank you.
For initalizing in ATTACH, I can put it into separate functions invoked at
other times.

But for cleanup in DETACH, how can I know when it will be detached by
application?
Is there any way to write my own entry function like dllmain for detach?

Cheers,
Kai


"Nick Ryan" <nryan@nryan.com> wrote in message
news:vlmsa422i8u089@corp.supernews.com...
> You can create a thread in DllMain, but you cannot wait for it to begin
> executing (among other DllMain restrictions). Follow the suggestions in
> the MSDN page on DllMain and put all complex init/uninit into separate
> functions invoked at other times.
>
> Kai wrote:
>
> > Hi, all
> >
> > I am trying write a dll which will have two thread A and B.
> > I want to initalize A and B when DLL_PROCESS_ATTACH, to terminate A and
B
> > when DLL_PROCESS_DETACH.
> > When initalizing, A create thread B, and wait B finish.
> > When terminating, A notify B, and wait B finish too.
> >
> > Thanks,
> > Kai
> >
> >
> >
>
> --
> Nick Ryan (MVP for DDK)
>