.net 2.0/3.0 RTM/SP1 missing functions

Aug 5, 2011 at 9:40 PM

Just had a bit of an issue with earlier .net versions, dropping this here as a note in case I don't get back with a patch

namespace Amib.Threading.Internal
{
#if _WINDOWS
// Prior to SP2 of .net 2/3.0 the wait functions needed exit context specified. The overloads added in SP2 pass a default value of false.
// Previous code was using the default false even though having an interface for exitContext, so it is unclear to me if these should be false or exitContext to support .net 2/3.0 RTM/SP1
internal static class STPEventWaitHandle
{
public const int WaitTimeout = Timeout.Infinite;

internal static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
{
return WaitHandle.WaitAll(waitHandles, millisecondsTimeout, false);
}

internal static int WaitAny(WaitHandle[] waitHandles)
{
return WaitHandle.WaitAny(waitHandles);
}

internal static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
{
return WaitHandle.WaitAny(waitHandles, millisecondsTimeout, false);
}

internal static bool WaitOne(WaitHandle waitHandle, int millisecondsTimeout, bool exitContext)
{
return waitHandle.WaitOne(millisecondsTimeout,false);
}
}

Dec 14, 2012 at 3:58 PM

Got the same issue with old version mscorlib.dll (2.0.50727.1433) of Framework 2.0

see : http://social.msdn.microsoft.com/Forums/en/chess/thread/d9f97db9-c1f8-489e-b095-61f309baf3ea

I'm using last version of SmartThreadPool 2.2.3.0, i passed exit context instead of false.

It seems the code in the ELSE condition was already good in the file STPWaitEventHandle

 

#if _WINDOWS ||  WINDOWS_PHONE
  internal static class STPEventWaitHandle
  {
    public const int WaitTimeout = Timeout.Infinite;
 
    internal static bool WaitAll( WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext )
    {
      return WaitHandle.WaitAll(waitHandles, millisecondsTimeout, exitContext);
    }
 
    internal static int WaitAny( WaitHandle[] waitHandles )
    {
      return WaitHandle.WaitAny(waitHandles);
    }
 
    internal static int WaitAny( WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext )
    {
      return WaitHandle.WaitAny(waitHandles, millisecondsTimeout, exitContext);
    }
 
    internal static bool WaitOne( WaitHandle waitHandle, int millisecondsTimeout, bool exitContext )
    {
      return waitHandle.WaitOne(millisecondsTimeout, exitContext);
    }
  }
#else
    internal static class STPEventWaitHandle
    {
        public const int WaitTimeout = Timeout.Infinite;

        internal static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
        {
            return WaitHandle.WaitAll(waitHandles, millisecondsTimeout, exitContext);
        }

        internal static int WaitAny(WaitHandle[] waitHandles)
        {
            return WaitHandle.WaitAny(waitHandles);
        }

        internal static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
        {
            return WaitHandle.WaitAny(waitHandles, millisecondsTimeout, exitContext);
        }

        internal static bool WaitOne(WaitHandle waitHandle, int millisecondsTimeout, bool exitContext)
        {
            return waitHandle.WaitOne(millisecondsTimeout, exitContext);
        }
    }
#endif
Aug 27, 2013 at 4:46 PM
I fixed this in a fork on github and requested a pull. But it doesn't seem like the source code is maintained unfortunately. You can find the fix/patch here: Pull Request