public void Dispose()
{
if (_process != null)
{
if (IsRunning())
_process.Kill();
_process.Dispose();
_process = null;
}
if (!string.IsNullOrEmpty(_executionPath))
{
for (var i = 0; i <= 5; i++)
{
try
{
Directory.Delete(GetExecutionDirPath(), true);
break;
}
catch (IOException)
{
Thread.Sleep(TimeSpan.FromMilliseconds(200));
if (i == 5)
throw;
}
catch(UnauthorizedAccessException)
{
Thread.Sleep(TimeSpan.FromMilliseconds(200));
if (i == 5)
throw;
}
}
}
}