Why AutoResetEvent and ManualResetEvent does not support name in the constructor?

Posted by Ikaso on Stack Overflow See other posts from Stack Overflow or by Ikaso
Published on 2010-05-12T07:28:13Z Indexed on 2010/05/12 7:34 UTC
Read the original article Hit count: 250

On .NET Framework 2.0 AutoResetEvent and ManualResetEvent inherit from EventWaitHandle. The EventWaitHandle class has 4 different constructors. 3 of the constructors support giving a name to the event. On the other hand both ManualResetEvent and AutoResetEvent do not support naming and provide a single constructor that receives the initialState. I can simply inherit from EventWaitHandle and write my own implementation of those classes that support all the constructor overloads, but I don't like to re-invent the wheel if I do not have to. My questions are:

  • Is there a special problem in naming events?
  • Do you have any idea why Microsoft did not support it?
  • Do you have a proposal better than inheriting from the EventWaitHandle class and calling the appropriate constructor as in the following example?
    public class MyAutoResetEvent: EventWaitHandle  
    {  
        public MyAutoResetEvent(bool initialState)  
            : base(initialState, EventResetMode.AutoReset)  
        {  
        }  
        public MyAutoResetEvent(bool initialState, string name)  
            : base(initialState, EventResetMode.AutoReset, name)  
        {  
        }  
        public MyAutoResetEvent(bool initialState, string name, out bool createdNew)  
            : base(initialState, EventResetMode.AutoReset, name, out createdNew)  
        {  
        }  
        public MyAutoResetEvent(bool initialState, string name, out bool createdNew, EventWaitHandleSecurity eventSecurity)  
            : base(initialState, EventResetMode.AutoReset, string.Empty, out createdNew, eventSecurity)  
        {  
        }  
    }  

© Stack Overflow or respective owner

Related posts about .net-2.0

Related posts about multithreading