Skip to content

Commit

Permalink
Find process by name if the ProcessID is 0, and only search for it on…
Browse files Browse the repository at this point in the history
…e time until it exits.
  • Loading branch information
xeropresence committed Nov 22, 2019
1 parent 48914b7 commit 73a02f0
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions DFAssist/Helpers/FFXIVNetworkProcessHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Linq;
using Advanced_Combat_Tracker;
using DFAssist.Contracts;
using DFAssist.Contracts.Duty;
Expand All @@ -21,19 +22,28 @@ public class FFXIVNetworkProcessHelper : IDisposable

private FFXIVNetworkMonitor _ffxivNetworkMonitor;


private Process _process;
public Process ActiveProcess
{
get
{
if (_ffxivNetworkMonitor == null)
return default;

var pid = Convert.ToInt32(_ffxivNetworkMonitor.ProcessID);
if(pid == 0)
return default;

var activeProcess = Process.GetProcessById(pid);
return activeProcess;
if (_process != null && !_process.HasExited)
return _process;

var pid = (int)_ffxivNetworkMonitor.ProcessID;
if (pid == 0)
{
_process = Process.GetProcessesByName("ffxiv_dx11").FirstOrDefault();
return _process;
}

_process = Process.GetProcessById(pid);
return _process;
}
}

Expand Down

0 comments on commit 73a02f0

Please sign in to comment.