Now sends netstate update request 3 seconds after a network change event. Added method for initiating a request with delay.
parent
6628030186
commit
022009680b
|
@ -7,9 +7,12 @@ using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.ServiceProcess;
|
using System.ServiceProcess;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
|
||||||
using WifiSitter;
|
using WifiSitter;
|
||||||
using WifiSitter.Model;
|
using WifiSitter.Model;
|
||||||
using WifiSitterGui.Helpers;
|
using WifiSitterGui.Helpers;
|
||||||
|
|
||||||
using XDMessaging;
|
using XDMessaging;
|
||||||
|
|
||||||
namespace WifiSitterGui.ViewModel
|
namespace WifiSitterGui.ViewModel
|
||||||
|
@ -42,7 +45,9 @@ namespace WifiSitterGui.ViewModel
|
||||||
|
|
||||||
|
|
||||||
private void Intitialize() {
|
private void Intitialize() {
|
||||||
|
// Get NetState
|
||||||
|
RequestNetworkState();
|
||||||
|
|
||||||
// Intermittent network state polling
|
// Intermittent network state polling
|
||||||
_netstateCheckTimer = new System.Timers.Timer();
|
_netstateCheckTimer = new System.Timers.Timer();
|
||||||
_netstateCheckTimer.AutoReset = true;
|
_netstateCheckTimer.AutoReset = true;
|
||||||
|
@ -50,6 +55,10 @@ namespace WifiSitterGui.ViewModel
|
||||||
_netstateCheckTimer.Elapsed += (o, e) => { RequestNetworkState(); };
|
_netstateCheckTimer.Elapsed += (o, e) => { RequestNetworkState(); };
|
||||||
_netstateCheckTimer.Start();
|
_netstateCheckTimer.Start();
|
||||||
|
|
||||||
|
// Connection state changed event handler setup
|
||||||
|
NetworkChange.NetworkAvailabilityChanged += (o, e) => { RequestNetworkState(3 * 1000); };
|
||||||
|
NetworkChange.NetworkAddressChanged += (o, e) => { RequestNetworkState(3 * 1000); };
|
||||||
|
|
||||||
Trace.WriteLine(String.Format("WifiSitter service msg channel: {0}", ServiceChannelName));
|
Trace.WriteLine(String.Format("WifiSitter service msg channel: {0}", ServiceChannelName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +76,7 @@ namespace WifiSitterGui.ViewModel
|
||||||
return _wsIpc;
|
return _wsIpc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MainWindowViewModel WindowVM {
|
public MainWindowViewModel WindowVM {
|
||||||
get { if (_windowVM == null) {
|
get { if (_windowVM == null) {
|
||||||
|
@ -78,6 +88,8 @@ namespace WifiSitterGui.ViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int IconSize { get { return 40; } }
|
||||||
|
|
||||||
internal string ServiceChannelName {
|
internal string ServiceChannelName {
|
||||||
get {
|
get {
|
||||||
if (_serviceChannel == null) {
|
if (_serviceChannel == null) {
|
||||||
|
@ -97,7 +109,11 @@ namespace WifiSitterGui.ViewModel
|
||||||
|
|
||||||
#region methods
|
#region methods
|
||||||
|
|
||||||
private void RequestNetworkState () {
|
public void RequestNetworkState(int Delay) {
|
||||||
|
Task.Delay(Delay).ContinueWith((task) => { RequestNetworkState(); }, TaskScheduler.FromCurrentSynchronizationContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RequestNetworkState () {
|
||||||
if (!String.IsNullOrEmpty(ServiceChannelName)) {
|
if (!String.IsNullOrEmpty(ServiceChannelName)) {
|
||||||
try {
|
try {
|
||||||
Trace.WriteLine("Checking for network state.");
|
Trace.WriteLine("Checking for network state.");
|
||||||
|
|
Loading…
Reference in New Issue