using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using Tango.FSE.Common;
using Tango.FSE.Common.Connectivity;
using Tango.Settings;
namespace Tango.FSE.UI.Connectivity
{
///
/// Represents the default implementation.
///
///
///
public class DefaultConnectivityProvider : BL.Connectivity.DefaultConnectivityProvider, IConnectivityProvider
{
private Timer _autoCheckTimer;
///
/// Gets or sets a value indicating whether to enable the automatic checking.
///
public bool EnableAutoCheck { get; set; }
///
/// Gets or sets the automatic checking interval.
///
public TimeSpan AutoCheckInterval { get; set; }
///
/// Initializes a new instance of the class.
///
public DefaultConnectivityProvider()
{
EnableAutoCheck = true;
AutoCheckInterval = TimeSpan.FromMinutes(5);
VerificationMethod = SettingsManager.Default.GetOrCreate().ConnectivityVerificationMethod;
_autoCheckTimer = new Timer(1000); //First time needs to be close to application start...
_autoCheckTimer.Elapsed += _autoCheckTimer_Elapsed;
_autoCheckTimer.Start();
}
private void _autoCheckTimer_Elapsed(object sender, ElapsedEventArgs e)
{
_autoCheckTimer.Interval = AutoCheckInterval.TotalMilliseconds;
CheckOnline();
}
}
}