Which SafeHandle implementation should I use to handle pens?

This day was a cool course for me in terms of pens, safety pens, PInvoke and many other things. I think it is slowly sinking, however I am still struggling with a few concepts:

How do I know which SafeHandle implementation I should use with different types of descriptors?

In particular, which implementation of SafeHandle should be used with process handlers (for example, in the PROCESS_INFORMATION structure returned from the CreateProcess call?

The only two public implementations I see are SafeFileHandle and SafeWaitHandle - none of them work in this case.

What should i use?

+4
source share
1 answer

SafeWaitHandle is appropriate. The process handle is actually a handle. You can call WaitForSingleObject () on it, and it will block until the process completes. The ReleaseHandle method calls CloseHandle (), if required. Are you sure the Process class is not doing what you need yet?

+7
source

All Articles