-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathUpdateChecker.cs
45 lines (38 loc) · 973 Bytes
/
UpdateChecker.cs
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
using System;
using System.Threading;
using System.Xml;
using ToDoLib;
using System.ComponentModel;
namespace Client
{
class UpdateChecker
{
public const string updateXMLUrl = @"https://raw.github.com/benrhughes/todotxt.net/master/Updates.xml";
public const string updateClientUrl = @"http://benrhughes.com/todotxt.net";
MainWindow _window;
public UpdateChecker(MainWindow window)
{
_window = window;
}
public void BeginCheck()
{
var worker = new BackgroundWorker();
var version = "";
worker.DoWork += (o, e) =>
{
try
{
var xDoc = new XmlDocument();
xDoc.Load(new XmlTextReader(updateXMLUrl));
version = xDoc.SelectSingleNode("//version").InnerText;
}
catch (Exception ex)
{
Log.Error("Error checking for updates", ex);
}
};
worker.RunWorkerCompleted += (o, e) => { _window.ToggleUpdateMenu(version); };
worker.RunWorkerAsync();
}
}
}