Skip to content

Commit

Permalink
新增 Everything调用超时
Browse files Browse the repository at this point in the history
  • Loading branch information
MakesYT committed May 7, 2024
1 parent 43a405e commit 7433b07
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 34 deletions.
38 changes: 19 additions & 19 deletions Core.Window/Everything/EverythingService.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
using Core.SDKs.Services;
using PluginCore;
using log4net;

namespace Core.Window.Everything;

public class EverythingService : IEverythingService
{
private static readonly ILog Log = LogManager.GetLogger(nameof(EverythingService));

public bool isRun()
{
if (IntPtr.Size == 8)
{
// 64-bit
Everything64.Everything_SetMax(1);

try
{
var task = Task.Run<bool>(()=> Everything64.Everything_QueryW(true));
task.Wait(TimeSpan.FromSeconds(1));

return task.Result;
}
catch (Exception)
var task = Task.Run<bool>(() => {
Everything64.Everything_SetMax(1);
return Everything64.Everything_QueryW(true);
});
if (!task.Wait(TimeSpan.FromSeconds(1)))
{
Log.Error("Everything调用超时");
return false;
}

return task.Result;
}
else
{
// 32-bit
try
{
var task = Task.Run<bool>(()=> Everything32.Everything_QueryW(true));
task.Wait(TimeSpan.FromSeconds(1));

return task.Result;
}
catch (Exception)
var task = Task.Run<bool>(() => {
Everything32.Everything_SetMax(1);
return Everything32.Everything_QueryW(true);
});
if (!task.Wait(TimeSpan.FromSeconds(1)))
{
Log.Error("Everything调用超时");
return false;
}

return task.Result;
}
}

}
34 changes: 19 additions & 15 deletions Core.Window/Everything/Tools.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
#region

using System.IO;
using System.Text;
using Core.SDKs.Services.Config;
using PluginCore;
using log4net;

#endregion

namespace Core.Window.Everything;

public class Tools
{
private static readonly ILog Log = LogManager.GetLogger("EverythingTools");

public static void main(List<string> Items)
{

if (IntPtr.Size == 8)
// 64-bit
{
amd64(Items);
}
else
// 32-bit
var task = Task.Run(() => {
if (IntPtr.Size == 8)
// 64-bit
{
amd64(Items);
}
else
// 32-bit
{
amd32(Items);
}
});
if (!task.Wait(TimeSpan.FromSeconds(1)))
{
amd32(Items);
Log.Error("Everything调用超时");
}


}

public static void amd32(List<string> Items)
{
Everything32.Everything_Reset();
Everything32.Everything_SetSearchW(String.Join("|",ConfigManger.Config!.everythingSearchExtensions));
Everything32.Everything_SetSearchW(String.Join("|", ConfigManger.Config!.everythingSearchExtensions));
Everything32.Everything_SetMatchCase(true);
Everything32.Everything_QueryW(true);
const int bufsize = 260;
Expand All @@ -48,7 +52,7 @@ public static void amd32(List<string> Items)
public static void amd64(List<string> Items)
{
Everything64.Everything_Reset();
Everything64.Everything_SetSearchW(String.Join("|",ConfigManger.Config!.everythingSearchExtensions));
Everything64.Everything_SetSearchW(String.Join("|", ConfigManger.Config!.everythingSearchExtensions));
Everything64.Everything_SetMatchCase(true);
Everything64.Everything_QueryW(true);
const int bufsize = 260;
Expand Down

0 comments on commit 7433b07

Please sign in to comment.