From: Art Baker [abaker@nfr.com] Sent: Friday, April 26, 2002 12:41 PM To: NT Developers Interest List Subject: [ntdev] RE: waiting on a system thread to finish KeWaitForSingleObject() requires a POINTER to the Thread object, not a HANDLE. 1.) Use ObReferenceObjectByHandle() to get a pointer to the Thread object. 2.) Call ZwClose() to get rid of your reference to the Thread object handle. 3.) When you don't need the pointer anymore (i.e., after you've finished your KeWaitFor...), use ObDereferenceObject() to release the Thread object pointer. > -----Original Message----- > From: bounce-ntdev-8523@lists.osr.com > [mailto:bounce-ntdev-8523@lists.osr.com]On Behalf Of skip > Sent: Friday, April 26, 2002 12:12 PM > To: NT Developers Interest List > Subject: [ntdev] waiting on a system thread to finish > > > I create a system thread with PsCreateSystemThread(...). I pass in a > pointer to the thread handle which gets set by a successful call. > > In user space, when you want to shut a worker thread down, you can ask the > thread to stop, and then wait on the thread handle you got back when you > created the thread. Often you have to do that to keep things from going > awry when your application is shutting down. > > I need to do the same thing in the kernel: I tell my kernel thread to > terminate, and it calls PsTerminateSystemThread(...) on itself. > > But I don't want any driver shutdown and cleanup to continue until that > thread is gone. What is the method used to know when > PsTerminateSystemThread(...) returns? > > I tried KeWaitForSingleObject(...) using the thread handle from > PsCreateSystemThread, but that didn't work. > > Thanks, > Skip > > --- > You are currently subscribed to ntdev as: abaker@nfr.com > To unsubscribe send a blank email to %%email.unsub%% --- You are currently subscribed to ntdev as: GlennEverhart@FirstUSA.com To unsubscribe send a blank email to leave-ntdev-247T@lists.osr.com