Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit ce00b9b

Browse files
committed
Don't block the main thread
Fix where task
1 parent 0cc03a2 commit ce00b9b

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public IObservable<Unit> Push(ILocalRepositoryModel repository)
189189
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201", Justification = "Prototype")]
190190
public async Task<bool> SyncSubmodules(ILocalRepositoryModel repository, IProgress<string> progress)
191191
{
192-
var exitCode = Where("git");
192+
var exitCode = await Where("git");
193193
if (exitCode != 0)
194194
{
195195
progress.Report(App.Resources.CouldntFindGitOnPath);
@@ -222,20 +222,23 @@ await Task.WhenAll(
222222
}
223223
}
224224

225-
static int Where(string fileName)
225+
static Task<int> Where(string fileName)
226226
{
227-
var cmdArguments = "/C WHERE /Q " + fileName;
228-
var startInfo = new ProcessStartInfo("cmd", cmdArguments)
227+
return Task.Run(() =>
229228
{
230-
UseShellExecute = false,
231-
CreateNoWindow = true
232-
};
229+
var cmdArguments = "/C WHERE /Q " + fileName;
230+
var startInfo = new ProcessStartInfo("cmd", cmdArguments)
231+
{
232+
UseShellExecute = false,
233+
CreateNoWindow = true
234+
};
233235

234-
using (var process = Process.Start(startInfo))
235-
{
236-
process.WaitForExit();
237-
return process.ExitCode;
238-
}
236+
using (var process = Process.Start(startInfo))
237+
{
238+
process.WaitForExit();
239+
return process.ExitCode;
240+
}
241+
});
239242
}
240243

241244
static async Task ReadLinesAsync(TextReader reader, IProgress<string> progress)

0 commit comments

Comments
 (0)