Mercurial > silverbladetech
comparison Stocks/Stocks.Service/StocksService.cs @ 4:57f20ba55884
Fix for webClientShim to use downloadString instead of downloadData
Refactoring and introduction of static TimedDelegates.Execute() helper method
author | stevenh7776 stevenhollidge@hotmail.com |
---|---|
date | Mon, 20 Feb 2012 23:04:58 +0700 |
parents | 29ed98d659e9 |
children | c812bca7b1ac |
comparison
equal
deleted
inserted
replaced
3:ef54074d5285 | 4:57f20ba55884 |
---|---|
5 using System.Threading.Tasks; | 5 using System.Threading.Tasks; |
6 using NLog; | 6 using NLog; |
7 using Stocks.Common; | 7 using Stocks.Common; |
8 using Stocks.Common.Events; | 8 using Stocks.Common.Events; |
9 using Stocks.Common.Models; | 9 using Stocks.Common.Models; |
10 using Stocks.Common.Core; | |
10 | 11 |
11 namespace Stocks.Service | 12 namespace Stocks.Service |
12 { | 13 { |
13 public class StocksService : IStocksService | 14 public class StocksService : IStocksService |
14 { | 15 { |
77 | 78 |
78 private void DownloadPrices() | 79 private void DownloadPrices() |
79 { | 80 { |
80 try | 81 try |
81 { | 82 { |
82 Stopwatch timeToDownload = new Stopwatch(); | 83 Stopwatch timeToDownload; |
83 | 84 |
84 while (IsActive) | 85 while (IsActive) |
85 { | 86 { |
86 timeToDownload.Restart(); | 87 string webResponse = TimedDelegates.Execute<string>( |
87 string webResponse = _webClient.DownloadString(_serviceUrl); | 88 _webClient.DownloadString, |
88 timeToDownload.Stop(); | 89 _serviceUrl, |
90 out timeToDownload); | |
89 | 91 |
90 PopulatePricesFromWebResponse(webResponse); | 92 PopulatePricesFromWebResponse(webResponse); |
91 UpdateStats(timeToDownload, webResponse); | 93 UpdateStats(timeToDownload, webResponse); |
92 } | 94 } |
93 } | 95 } |