Close of event

This is a discussion on Close of event within the C# Programming forums, part of the General Programming Boards category; Hello everyone, For ManualResetEvent and AutoResetEvent, I noticed some samples which does not call Close after using them. 1. I ...

  1. #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

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

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

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