Home Forums Support About the AutoResetEvent

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2634
    Anonymous
    Inactive

    Dear marcF
    My teacher tell me in the .net framework2.0

    If I use AutoResetEvent like this:

    AutoResetEvent  returnWaitSignal=new AutoResetEvent();
    if (!returnWaitSignal.WaitOne(returnPacketTimeOutMilliSeconds))
                {
                    RemoveIncomingPacketHandler(expectedReturnPacketTypeStr, SendReceiveDelegate);
                    throw new ExpectedReturnTimeoutException("Timeout occurred after " + returnPacketTimeOutMilliSeconds.ToString() + "ms waiting for response packet of type '" + expectedReturnPacketTypeStr + "'.");
                }

    should change the code to:

    AutoResetEvent  returnWaitSignal=new AutoResetEvent();
     if (!returnWaitSignal.WaitOne(returnPacketTimeOutMilliSeconds,true))
                {
                    RemoveIncomingPacketHandler(expectedReturnPacketTypeStr, SendReceiveDelegate);
                    throw new ExpectedReturnTimeoutException("Timeout occurred after " + returnPacketTimeOutMilliSeconds.ToString() + "ms waiting for response packet of type '" + expectedReturnPacketTypeStr + "'.");
                }

    because in .net framework 2.0 the waitone method has some problem when use only one paramter

    I test it in my computer .the System is window 2003

    • This topic was modified 10 years, 6 months ago by . Reason: Edited to add code tags
    #2636
    Anonymous
    Inactive

    Dear marcF
    Thank you very much,I have received your email contains the 3.0.1 download link.
    if you release new version. Where I can find the new version download link ,Thanks.

    #2637
    Anonymous
    Inactive

    Your teacher is correct, here is a good reference – http://blog.darrenstokes.com/2009/03/30/watch-out-for-those-waitone-overloads-when-you-need-backwards-compatibility/

    To be honest I have never heard of this before and the above article does not make it clear whether the issue is automatically resolved at compile time. It seems like a relatively easy fix, I’ll add a bug report for it and will fix in the future.

    Regards,
    Marc

    #2638
    Anonymous
    Inactive

    I test it .the issue is not automatically resolved at compile time.

    the vs version is vs2010.

    #2649
    Anonymous
    Inactive

    I’ve created a bug report for this issue – https://bitbucket.org/MarcF/networkcomms.net/issue/48/net2-waitone-override-missing. We should be able to resolve this for the next release.

    Regards,
    Marc

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.