mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
Added timeout to get window info list function for unexpected possibilities
This commit is contained in:
parent
3e2f34468c
commit
7e042c10a8
2 changed files with 29 additions and 2 deletions
|
@ -182,7 +182,7 @@ public override void Prepare()
|
|||
WindowsRectangleList wla = new WindowsRectangleList();
|
||||
wla.IgnoreHandle = handle;
|
||||
wla.IncludeChildWindows = AreaManager.IncludeControls;
|
||||
AreaManager.Windows = wla.GetWindowsRectangleList();
|
||||
AreaManager.Windows = wla.GetWindowInfoListAsync(3000);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ You should have received a copy of the GNU General Public License
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX.ScreenCaptureLib
|
||||
{
|
||||
|
@ -38,7 +40,32 @@ public class WindowsRectangleList
|
|||
private List<SimpleWindowInfo> windows;
|
||||
private HashSet<IntPtr> parentHandles;
|
||||
|
||||
public List<SimpleWindowInfo> GetWindowsRectangleList()
|
||||
public List<SimpleWindowInfo> GetWindowInfoListAsync(int timeout)
|
||||
{
|
||||
List<SimpleWindowInfo> windowInfoList = null;
|
||||
|
||||
Thread t = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
windowInfoList = GetWindowInfoList();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
});
|
||||
|
||||
t.Start();
|
||||
|
||||
if (!t.Join(timeout))
|
||||
{
|
||||
t.Abort();
|
||||
}
|
||||
|
||||
return windowInfoList;
|
||||
}
|
||||
|
||||
public List<SimpleWindowInfo> GetWindowInfoList()
|
||||
{
|
||||
windows = new List<SimpleWindowInfo>();
|
||||
parentHandles = new HashSet<IntPtr>();
|
||||
|
|
Loading…
Reference in a new issue