diff --git a/src/MeoAsstGui/ViewModels/MainFunctionViewModel.cs b/src/MeoAsstGui/ViewModels/MainFunctionViewModel.cs index ccf791a490..233c2247e6 100644 --- a/src/MeoAsstGui/ViewModels/MainFunctionViewModel.cs +++ b/src/MeoAsstGui/ViewModels/MainFunctionViewModel.cs @@ -1,6 +1,7 @@ using Stylet; using StyletIoC; - +using System.Threading.Tasks; + namespace MeoAsstGui { public class MainFunctionViewModel : Screen @@ -264,10 +265,14 @@ namespace MeoAsstGui CreditShoppingCheckBoxIsEnable = true; } - public void StartSanity() + public async void StartSanity() { - var asstProxy = _container.Get(); - bool catched = asstProxy.AsstCatchDefault(); + var asstProxy = _container.Get(); + var task = Task.Run(() => + { + return asstProxy.AsstCatchDefault(); + }); + bool catched = await task; CatchStatus = "捕获模拟器窗口:" + catched; if (!asstProxy.AsstStartSanity()) { @@ -284,10 +289,15 @@ namespace MeoAsstGui } } - public void Visit() + public async void Visit() { - var asstProxy = _container.Get(); - bool catched = asstProxy.AsstCatchDefault(); + var asstProxy = _container.Get(); + var task = Task.Run(() => + { + return asstProxy.AsstCatchDefault(); + }); + bool catched = await task; + CatchStatus = "捕获模拟器窗口:" + catched; if (!asstProxy.AsstStartVisit(CreditShopping)) { diff --git a/src/MeoAsstGui/ViewModels/RecruitViewModel.cs b/src/MeoAsstGui/ViewModels/RecruitViewModel.cs index 8e5ff04d32..f67b5939be 100644 --- a/src/MeoAsstGui/ViewModels/RecruitViewModel.cs +++ b/src/MeoAsstGui/ViewModels/RecruitViewModel.cs @@ -1,7 +1,9 @@ using Stylet; using StyletIoC; using System.Collections.Generic; - + +using System.Threading.Tasks; + namespace MeoAsstGui { public class RecruitViewModel : Screen @@ -98,12 +100,18 @@ namespace MeoAsstGui } } - public void StartCalc() + public async void StartCalc() { - var asstProxy = _container.Get(); - if (!asstProxy.AsstCatchDefault()) - { - return; + var asstProxy = _container.Get(); + var task = Task.Run(() => + { + return asstProxy.AsstCatchDefault(); + }); + bool catchd = await task; + if (!catchd) + { + RecruitInfo = "捕获模拟器窗口失败"; + return; } RecruitInfo = "正在识别……"; RecruitResult = "";