Fixed null errors when service isn't running.

systray
Sean McArdle 2016-11-21 14:27:34 -08:00
parent 7bb46addb7
commit d912745622
1 changed files with 4 additions and 3 deletions

View File

@ -49,16 +49,17 @@ namespace WifiSitterGui.ViewModel
}
public List<SimpleNic> Nics { get { return NetState.Nics; } }
public List<SimpleNic> Nics { get { return NetState?.Nics; } }
public string ServiceState {
get {
try { if (_sc == null) _sc = new ServiceController("WifiSitter"); }
ServiceControllerStatus status;
try { if (_sc == null) _sc = new ServiceController("WifiSitter"); status = _sc.Status; }
catch { return "No Service"; }
_sc.Refresh();
switch (_sc.Status) {
switch (status) {
case ServiceControllerStatus.Running:
return "Running";
case ServiceControllerStatus.Stopped: