From 854dcd1abddc3eef33da953592deb61133e5e7ed Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 1 May 2013 23:00:46 +0100 Subject: Fix SmartThreadPool line endings in recent update from dos to unix --- .../SmartThreadPool/EventWaitHandleFactory.cs | 164 ++++++++++----------- 1 file changed, 82 insertions(+), 82 deletions(-) (limited to 'ThirdParty/SmartThreadPool/EventWaitHandleFactory.cs') diff --git a/ThirdParty/SmartThreadPool/EventWaitHandleFactory.cs b/ThirdParty/SmartThreadPool/EventWaitHandleFactory.cs index 2f8c55b..3c9c849 100644 --- a/ThirdParty/SmartThreadPool/EventWaitHandleFactory.cs +++ b/ThirdParty/SmartThreadPool/EventWaitHandleFactory.cs @@ -1,82 +1,82 @@ -using System.Threading; - -#if (_WINDOWS_CE) -using System; -using System.Runtime.InteropServices; -#endif - -namespace Amib.Threading.Internal -{ - /// - /// EventWaitHandleFactory class. - /// This is a static class that creates AutoResetEvent and ManualResetEvent objects. - /// In WindowCE the WaitForMultipleObjects API fails to use the Handle property - /// of XxxResetEvent. It can use only handles that were created by the CreateEvent API. - /// Consequently this class creates the needed XxxResetEvent and replaces the handle if - /// it's a WindowsCE OS. - /// - public static class EventWaitHandleFactory - { - /// - /// Create a new AutoResetEvent object - /// - /// Return a new AutoResetEvent object - public static AutoResetEvent CreateAutoResetEvent() - { - AutoResetEvent waitHandle = new AutoResetEvent(false); - -#if (_WINDOWS_CE) - ReplaceEventHandle(waitHandle, false, false); -#endif - - return waitHandle; - } - - /// - /// Create a new ManualResetEvent object - /// - /// Return a new ManualResetEvent object - public static ManualResetEvent CreateManualResetEvent(bool initialState) - { - ManualResetEvent waitHandle = new ManualResetEvent(initialState); - -#if (_WINDOWS_CE) - ReplaceEventHandle(waitHandle, true, initialState); -#endif - - return waitHandle; - } - -#if (_WINDOWS_CE) - - /// - /// Replace the event handle - /// - /// The WaitHandle object which its handle needs to be replaced. - /// Indicates if the event is a ManualResetEvent (true) or an AutoResetEvent (false) - /// The initial state of the event - private static void ReplaceEventHandle(WaitHandle waitHandle, bool manualReset, bool initialState) - { - // Store the old handle - IntPtr oldHandle = waitHandle.Handle; - - // Create a new event - IntPtr newHandle = CreateEvent(IntPtr.Zero, manualReset, initialState, null); - - // Replace the old event with the new event - waitHandle.Handle = newHandle; - - // Close the old event - CloseHandle (oldHandle); - } - - [DllImport("coredll.dll", SetLastError = true)] - public static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName); - - //Handle - [DllImport("coredll.dll", SetLastError = true)] - public static extern bool CloseHandle(IntPtr hObject); -#endif - - } -} +using System.Threading; + +#if (_WINDOWS_CE) +using System; +using System.Runtime.InteropServices; +#endif + +namespace Amib.Threading.Internal +{ + /// + /// EventWaitHandleFactory class. + /// This is a static class that creates AutoResetEvent and ManualResetEvent objects. + /// In WindowCE the WaitForMultipleObjects API fails to use the Handle property + /// of XxxResetEvent. It can use only handles that were created by the CreateEvent API. + /// Consequently this class creates the needed XxxResetEvent and replaces the handle if + /// it's a WindowsCE OS. + /// + public static class EventWaitHandleFactory + { + /// + /// Create a new AutoResetEvent object + /// + /// Return a new AutoResetEvent object + public static AutoResetEvent CreateAutoResetEvent() + { + AutoResetEvent waitHandle = new AutoResetEvent(false); + +#if (_WINDOWS_CE) + ReplaceEventHandle(waitHandle, false, false); +#endif + + return waitHandle; + } + + /// + /// Create a new ManualResetEvent object + /// + /// Return a new ManualResetEvent object + public static ManualResetEvent CreateManualResetEvent(bool initialState) + { + ManualResetEvent waitHandle = new ManualResetEvent(initialState); + +#if (_WINDOWS_CE) + ReplaceEventHandle(waitHandle, true, initialState); +#endif + + return waitHandle; + } + +#if (_WINDOWS_CE) + + /// + /// Replace the event handle + /// + /// The WaitHandle object which its handle needs to be replaced. + /// Indicates if the event is a ManualResetEvent (true) or an AutoResetEvent (false) + /// The initial state of the event + private static void ReplaceEventHandle(WaitHandle waitHandle, bool manualReset, bool initialState) + { + // Store the old handle + IntPtr oldHandle = waitHandle.Handle; + + // Create a new event + IntPtr newHandle = CreateEvent(IntPtr.Zero, manualReset, initialState, null); + + // Replace the old event with the new event + waitHandle.Handle = newHandle; + + // Close the old event + CloseHandle (oldHandle); + } + + [DllImport("coredll.dll", SetLastError = true)] + public static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName); + + //Handle + [DllImport("coredll.dll", SetLastError = true)] + public static extern bool CloseHandle(IntPtr hObject); +#endif + + } +} -- cgit v1.1