Removed async update check due to threading issue
This commit is contained in:
parent
94146467a3
commit
4185c3dbde
|
@ -8,13 +8,13 @@ namespace Filtration.Tests.Services
|
|||
public class TestHTTPService
|
||||
{
|
||||
[Test]
|
||||
public async void GetContent_FetchesDataFromUrl()
|
||||
public void GetContent_FetchesDataFromUrl()
|
||||
{
|
||||
// Arrange
|
||||
var service = new HTTPService();
|
||||
|
||||
// Act
|
||||
var result = await service.GetContentAsync("http://ben-wallis.github.io/Filtration/filtration_version.xml");
|
||||
var result = service.GetContent("http://ben-wallis.github.io/Filtration/filtration_version.xml");
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(result);
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Filtration.Services
|
||||
{
|
||||
internal interface IHTTPService
|
||||
{
|
||||
Task<string> GetContentAsync(string url);
|
||||
string GetContent(string url);
|
||||
}
|
||||
|
||||
internal class HTTPService : IHTTPService
|
||||
{
|
||||
public async Task<string> GetContentAsync(string url)
|
||||
public string GetContent(string url)
|
||||
{
|
||||
var urlUri = new Uri(url);
|
||||
|
||||
var request = WebRequest.Create(urlUri);
|
||||
|
||||
var response = await request.GetResponseAsync();
|
||||
var response = request.GetResponse();
|
||||
using (var s = response.GetResponseStream())
|
||||
{
|
||||
using (var sr = new StreamReader(s))
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using Filtration.Models;
|
||||
|
||||
|
@ -7,7 +6,7 @@ namespace Filtration.Services
|
|||
{
|
||||
internal interface IUpdateCheckService
|
||||
{
|
||||
Task<UpdateData> GetUpdateDataAsync();
|
||||
UpdateData GetUpdateData();
|
||||
}
|
||||
|
||||
internal class UpdateCheckService : IUpdateCheckService
|
||||
|
@ -20,9 +19,9 @@ namespace Filtration.Services
|
|||
_httpService = httpService;
|
||||
}
|
||||
|
||||
public async Task<UpdateData> GetUpdateDataAsync()
|
||||
public UpdateData GetUpdateData()
|
||||
{
|
||||
var updateXml = await _httpService.GetContentAsync(UpdateDataUrl);
|
||||
var updateXml = _httpService.GetContent(UpdateDataUrl);
|
||||
return (DeserializeUpdateData(updateXml));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,14 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
|
@ -191,10 +193,7 @@ namespace Filtration.ViewModels
|
|||
}
|
||||
});
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await CheckForUpdatesAsync();
|
||||
}).Wait();
|
||||
CheckForUpdates();
|
||||
}
|
||||
|
||||
public RelayCommand OpenScriptCommand { get; private set; }
|
||||
|
@ -238,13 +237,13 @@ namespace Filtration.ViewModels
|
|||
public RelayCommand ClearFiltersCommand { get; private set; }
|
||||
|
||||
|
||||
public async Task CheckForUpdatesAsync()
|
||||
public void CheckForUpdates()
|
||||
{
|
||||
var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _updateCheckService.GetUpdateDataAsync();
|
||||
var result = _updateCheckService.GetUpdateData();
|
||||
|
||||
if (result.LatestVersionMajorPart >= assemblyVersion.FileMajorPart &&
|
||||
result.LatestVersionMinorPart > assemblyVersion.FileMinorPart)
|
||||
|
|
Loading…
Reference in New Issue