public void CleanUp() {
if (_gameProcess != null && !_gameProcess.HasExitedSafe()) {
try {
_gameProcess.Kill();
} catch (Exception) {
// ignored
}
}
_gameProcess?.Dispose();
_gameProcess = null;
if (_acLauncher == null || new FileInfo(_acLauncher).Length > ApproximateAcstarterSize) return;
Thread.Sleep(200);
var isRestored = false;
for (var i = 0; i < 10 && File.Exists(_acLauncherBackup); i++) {
try {
if (!isRestored) {
if (File.Exists(_acLauncher)) {
File.Delete(_acLauncher);
}
File.Copy(_acLauncherBackup, _acLauncher);
isRestored = true;
}
File.Delete(_acLauncherBackup);
} catch (IOException) { }
Thread.Sleep(WaitIter);
}
if (File.Exists(_acLauncherBackup)) {
throw new Exception("Cannot restore original AssettoCorsa.exe.");
}
}