Пример #1
0
 private static void EnumChildWindows(RunningWindowTableItemCollection list, IntPtr mainHandle, IntPtr handle, int maximumResultCount)
 {
     Tools.WndUtils.ChildWindowEnumerator childEnumerator =
         new Tools.WndUtils.ChildWindowEnumerator(handle);
     IntPtr[] childWindows = childEnumerator.EnumerateWindows(10000);
     if (null != childWindows)
     {
         foreach (IntPtr item in childWindows)
         {
             DoAccTest(list, mainHandle, item, maximumResultCount);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Enumerates all child windows. WARNING: The method returns null if operation timeout is reached.
        /// </summary>
        /// <param name="milliSecondsTimeout">a timeout for the operation. when a window is busy or non responding these method freeze. you can handle this with the operation timeout</param>
        /// <returns>result array or null</returns>
        public IntPtr[] EnumerateWindows(int milliSecondsTimeout)
        {
            if (milliSecondsTimeout < 0)
            {
                throw new ArgumentOutOfRangeException("milliSecondsTimeout");
            }

            try
            {
                lock (_lockInstance)
                {
                    Result.Clear();
                    _currentInstance = this;
                    Thread           thread1     = new Thread(new ParameterizedThreadStart(EnumerateWindowsAsync));
                    WaitHandle[]     waitHandles = new WaitHandle[1];
                    ManualResetEvent mre1        = new ManualResetEvent(false);
                    waitHandles[0] = mre1;
                    thread1.Start(mre1);
                    bool result = WaitHandle.WaitAll(waitHandles, milliSecondsTimeout);
                    if (!result)
                    {
                        thread1.Abort();
                        Result.Clear();
                        _currentInstance = null;
                        return(null);
                    }
                    else
                    {
                        _currentInstance = null;
                    }
                }
                return(Result.ToArray());
            }
            catch (Exception exception)
            {
                DebugConsole.Default.WriteException(exception);
                throw;
            }
        }
Пример #3
0
        /// <summary>
        /// Enumerates all child windows. WARNING: The method returns null if operation timeout is reached.
        /// </summary>
        /// <param name="milliSecondsTimeout">a timeout for the operation. when a window is busy or non responding these method freeze. you can handle this with the operation timeout</param>
        /// <returns>result array or null</returns>
        public IntPtr[] EnumerateWindows(int milliSecondsTimeout)
        {
            if (milliSecondsTimeout < 0)
                throw new ArgumentOutOfRangeException("milliSecondsTimeout");

            try
            {
                lock (_lockInstance)
                {
                    Result.Clear();
                    _currentInstance = this;
                    Thread thread1 = new Thread(new ParameterizedThreadStart(EnumerateWindowsAsync));
                    WaitHandle[] waitHandles = new WaitHandle[1];
                    ManualResetEvent mre1 = new ManualResetEvent(false);
                    waitHandles[0] = mre1;
                    thread1.Start(mre1);
                    bool result = WaitHandle.WaitAll(waitHandles, milliSecondsTimeout);
                    if (!result)
                    {
                        thread1.Abort();
                        Result.Clear();
                        _currentInstance = null;
                        return null;
                    }
                    else
                    {
                        _currentInstance = null;
                    }
                }
                return Result.ToArray();
            }
            catch (Exception exception)
            {
                DebugConsole.Default.WriteException(exception);
                throw;
            }
        }
Пример #4
0
 private static void EnumChildWindows(RunningWindowTableItemCollection list, IntPtr mainHandle, IntPtr handle, int maximumResultCount)
 {
     Tools.WndUtils.ChildWindowEnumerator childEnumerator =
                 new Tools.WndUtils.ChildWindowEnumerator(handle);
     IntPtr[] childWindows = childEnumerator.EnumerateWindows(10000);
     if (null != childWindows)
     {
         foreach (IntPtr item in childWindows)
             DoAccTest(list, mainHandle, item, maximumResultCount);
     }
 }