blob: 1991d3ae635811c347a74561a11b61c470df78ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
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
{
/// <summary>
/// Represents the default <see cref="IConnectivityProvider"/> implementation.
/// </summary>
/// <seealso cref="Tango.FSE.BL.Connectivity.DefaultConnectivityProvider" />
/// <seealso cref="Tango.FSE.Common.Connectivity.IConnectivityProvider" />
public class DefaultConnectivityProvider : BL.Connectivity.DefaultConnectivityProvider, IConnectivityProvider
{
private Timer _autoCheckTimer;
/// <summary>
/// Gets or sets a value indicating whether to enable the automatic checking.
/// </summary>
public bool EnableAutoCheck { get; set; }
/// <summary>
/// Gets or sets the automatic checking interval.
/// </summary>
public TimeSpan AutoCheckInterval { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="DefaultConnectivityProvider"/> class.
/// </summary>
public DefaultConnectivityProvider()
{
EnableAutoCheck = true;
AutoCheckInterval = TimeSpan.FromMinutes(5);
VerificationMethod = SettingsManager.Default.GetOrCreate<FSESettings>().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();
}
}
}
|