mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
fix: accessing dummy
in multi-threads throws exception
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
2fc03025ee
commit
91c5c96afc
1 changed files with 12 additions and 5 deletions
|
@ -73,6 +73,7 @@ namespace SourceGit.Commands
|
||||||
};
|
};
|
||||||
|
|
||||||
var dummy = null as Process;
|
var dummy = null as Process;
|
||||||
|
var dummyProcLock = new object();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
proc.Start();
|
proc.Start();
|
||||||
|
@ -83,10 +84,9 @@ namespace SourceGit.Commands
|
||||||
dummy = proc;
|
dummy = proc;
|
||||||
CancellationToken.Register(() =>
|
CancellationToken.Register(() =>
|
||||||
{
|
{
|
||||||
if (dummy is { HasExited: false })
|
lock (dummyProcLock)
|
||||||
{
|
{
|
||||||
dummy.CancelErrorRead();
|
if (dummy is { HasExited: false })
|
||||||
dummy.CancelOutputRead();
|
|
||||||
dummy.Kill();
|
dummy.Kill();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -104,7 +104,14 @@ namespace SourceGit.Commands
|
||||||
proc.BeginErrorReadLine();
|
proc.BeginErrorReadLine();
|
||||||
proc.WaitForExit();
|
proc.WaitForExit();
|
||||||
|
|
||||||
|
if (dummy != null)
|
||||||
|
{
|
||||||
|
lock (dummyProcLock)
|
||||||
|
{
|
||||||
dummy = null;
|
dummy = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int exitCode = proc.ExitCode;
|
int exitCode = proc.ExitCode;
|
||||||
proc.Close();
|
proc.Close();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue