Skip to content

Commit

Permalink
Attempt to gracefully exit process if possible with "terminate"
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jun 22, 2024
1 parent cdbf10b commit 33b18b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 14 additions & 1 deletion UEVR/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using static UEVR.SharedMemory;
using System.Threading.Channels;
using System.Security.Principal;
using System.Windows.Media.Animation;

namespace UEVR {
class GameSettingEntry : INotifyPropertyChanged {
Expand Down Expand Up @@ -979,7 +980,19 @@ private void Inject_Clicked(object sender, RoutedEventArgs e) {

if (pid != null) {
var target = Process.GetProcessById((int)pid);
target.CloseMainWindow();

if (target == null || target.HasExited) {
return;
}

target.WaitForInputIdle(100);

SharedMemory.SendCommand(SharedMemory.Command.Quit);

if (target.WaitForExit(2000)) {
return;
}

target.Kill();
}
} catch(Exception) {
Expand Down
3 changes: 2 additions & 1 deletion UEVR/UEVRSharedMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public struct Data {

public enum Command {
ReloadConfig,
ConfigSetupAcknowledged
ConfigSetupAcknowledged,
Quit
};

public static string SharedMemoryName = "UnrealVRMod";
Expand Down

0 comments on commit 33b18b0

Please sign in to comment.