【问题标题】:Get internet bandwidth/speed information in a Windows Store App在 Windows 应用商店应用程序中获取 Internet 带宽/速度信息
【发布时间】:2013-08-28 12:36:11
【问题描述】:

我需要在我的 Windows Store (c#) 应用程序中获得有关实际互联网速度的相对接近的信息。我需要这个,因为用户可以播放在线托管的视频。始终有两个版本的视频可用(高质量/低质量)。 App应根据用户的网速,流式传输相应的视频版本。

我尝试下载一个 5MB 的虚拟文件并查看此任务所需的时间(以了解互联网速度)。但我发现结果过于分散和多变。使用更大的文件可能会得到更好的结果,但这不利于用户体验。

有没有更简单的方法来获取当前的 Internet 带宽?

P.S.:IIS 平滑流式传输是不可能的。

PPS.:也许这是正确的道路,但我不知道如何在我的情况下使用这个类:StreamSocketInformation.BandwidthStatistics

【问题讨论】:

  • 现在可用的可能不是 10 秒后可用的。这就是不受您的应用程序直接控制的资源(例如带宽)的性质。

标签: c# windows-8 windows-runtime microsoft-metro


【解决方案1】:

通过以下代码获取下载速度。

var connectionProfile = NetworkInformation.GetInternetConnectionProfile();
var dataPlanStatus = connectionProfile.GetDataPlanStatus();
ulong? outboundBandwidth = dataPlanStatus.OutboundBitsPerSecond;
if (outboundBandwidth.HasValue)
{
    System.Diagnostics.Debug.WriteLine("OutboundBitsPerSecond : " + outboundBandwidth + "\n");
}
else
{
    System.Diagnostics.Debug.WriteLine("OutboundBitsPerSecond : Not Defined\n");
}

Connecting to networks and web services (Windows Store apps using C#/VB/C++ and XAML)

Connection state and cost management (Windows Store apps using C#/VB/C++ and XAML)

【讨论】:

  • 谢谢,但此代码示例适用于计量连接 afaik。 outboundBandwith 没有价值...
  • 嗯,我有时会得到一个值,有时是零。要获得关于带宽的公平信息似乎并不容易。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-22
  • 1970-01-01
  • 1970-01-01
  • 2012-12-08
  • 1970-01-01
相关资源
最近更新 更多