public async Task<CountryInfo> GetLocation(string ipAddress) { return await Task.Run<CountryInfo>(() => { try { GeoIPService.GeoIP info = new GeoIPService.GeoIPServiceSoapClient().GetGeoIP(ipAddress); return new CountryInfo { Code = info.CountryCode, Name = info.CountryName }; } catch { return new CountryInfo { Code = null, Name = null }; } }, Context.Get<CancellationTokenSource>().Token); }
public async Task <CountryInfo> GetLocation(string ipAddress) { return(await Task.Run <CountryInfo>(() => { try { GeoIPService.GeoIP info = new GeoIPService.GeoIPServiceSoapClient().GetGeoIP(ipAddress); return new CountryInfo { Code = info.CountryCode, Name = info.CountryName }; } catch { return new CountryInfo { Code = null, Name = null }; } }, Context.Get <CancellationTokenSource>().Token)); }