Fixed null errors when service isn't running.
parent
7bb46addb7
commit
d912745622
|
@ -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 {
|
public string ServiceState {
|
||||||
get {
|
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"; }
|
catch { return "No Service"; }
|
||||||
|
|
||||||
_sc.Refresh();
|
_sc.Refresh();
|
||||||
switch (_sc.Status) {
|
switch (status) {
|
||||||
case ServiceControllerStatus.Running:
|
case ServiceControllerStatus.Running:
|
||||||
return "Running";
|
return "Running";
|
||||||
case ServiceControllerStatus.Stopped:
|
case ServiceControllerStatus.Stopped:
|
||||||
|
|
Loading…
Reference in New Issue