HighTechTalks DotNet Forums  

Closing SafeHandle

Dotnet Framework microsoft.public.dotnet.framework


Discuss Closing SafeHandle in the Dotnet Framework forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
valentin tihomirov
 
Posts: n/a

Default Closing SafeHandle - 10-29-2007 , 11:21 AM






The SafeFileHandle is an extension of SafeHandle, which requires Close() or
Dispose() after used according to the docs. There are many examples on using
the named pipes in .Net. All the examples expoit
FileStream(CreateFile(PIPE_NAME)). You may look at
http://blog.paranoidferret.com/index...pes-in-csharp/
for one. But none of the examples closes the handle nor the 'using'
directive is used!

Should I?



Reply With Quote
  #2  
Old   
Henning Krause [MVP - Exchange]
 
Posts: n/a

Default Re: Closing SafeHandle - 10-29-2007 , 01:09 PM






Hello,

the SafeHandle will eventually disposed by its destructor. But calling the
Dispose method when you no longer need the SafeHandle is a very good idea -
it deterministically releases the unmanged handle and removes the instance
from the finalization queue which tracks all instances with a finalizer.

Kind regards,
Henning Krause

"valentin tihomirov" <V_tihomirov (AT) best (DOT) ee> wrote

Quote:
The SafeFileHandle is an extension of SafeHandle, which requires Close()
or Dispose() after used according to the docs. There are many examples on
using the named pipes in .Net. All the examples expoit
FileStream(CreateFile(PIPE_NAME)). You may look at
http://blog.paranoidferret.com/index...pes-in-csharp/
for one. But none of the examples closes the handle nor the 'using'
directive is used!

Should I?



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.