C Board  

Go Back   C Board > General Programming Boards > C# Programming

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 06-02-2008, 06:23 AM   #1
Registered User
 
Join Date: May 2006
Posts: 1,579
Close of event

Hello everyone,


For ManualResetEvent and AutoResetEvent, I noticed some samples which does not call Close after using them.

1.

I think to be of good practices, we should call Close after using them -- the reason is both ManualResetEvent and AutoResetEvent wraps native resources and release immediately will make system have more capability to serve in the future?

2.

What native resources are wrapped?


thanks in advance,
George
George2 is offline  
Old 06-02-2008, 01:10 PM   #2
the hat of redundancy hat
 
nvoigt's Avatar
 
Join Date: Aug 2001
Location: Hannover, Germany
Posts: 2,769
1) Yes. Samples are sometimes sloppy. However, you can also reuse an event, if you need one many times, don't new/close one every time. Just reuse the one you already have. If an event will live over the duration of the whole application, it's not neccessary to close it more than once in the end.

2) On a very wild guess, I'd say it's wrapping an event HANDLE created by the CreateEvent-API m-)
__________________
hth
-nv

She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

When in doubt, read the FAQ.
Then ask a smart question.
nvoigt is offline  
Closed Thread

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lame null append cause buffer to crash cmoo C Programming 8 12-29-2008 03:27 AM
open() and close() SoFarAway C Programming 3 04-08-2005 01:16 PM
XWindows- Close window event? Exile Linux Programming 8 01-09-2005 10:39 PM
Ghost in the CD Drive Natase A Brief History of Cprogramming.com 17 10-12-2001 05:38 PM


All times are GMT -6. The time now is 08:11 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22