private async void ExecuteSpeedTest(SpeedTestSource source, Server server = null) { try { SpeedGrid.IsEnabled = false; DownloadSpeed speed = null; if (source == SpeedTestSource.Speedtest) { speed = await SpeedTestClient.GetDownloadSpeed(server, SpeedTestUnit.KiloBitsPerSecond); } else { speed = await FastClient.GetDownloadSpeed(SpeedTestUnit.KiloBitsPerSecond); } var message = $"Source: {speed.Source} Download Speed: {speed?.Speed} {speed.Unit}"; if (speed?.Server?.Id != null) { message += $" (Server Id = {speed?.Server?.Id})"; } ShowMessage(message); SpeedGrid.IsEnabled = true; } catch (System.Exception ex) { ShowMessage(ex.Message); SpeedGrid.IsEnabled = true; } }
internal static string ToSourceString(this SpeedTestSource source) { if (source == SpeedTestSource.Fast) { return("fast.com"); } return("speedtest.net"); }