Silverlight中的连接速度测试

时间:2009-06-11 15:41:06

标签: silverlight connection performance

我想在Silverlight 3应用程序上添加某种“连接质量”指示器,以便用户了解其连接速度。这可以是一个变为红色,黄色或绿色的图标,以提供用户应该期望的性能的基本概念。在Silverlight中测量连接速度的好方法是什么?

1 个答案:

答案 0 :(得分:2)

我会启动一个网络请求,然后花费多长时间。类似的东西:

public partial class Page:UserControl {     DateTime已开始;

public Page()
{
    InitializeComponent();

    WebClient client = new WebClient();
    client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
    started = DateTime.Now;
    client.DownloadStringAsync(new Uri("SomeKnownURI...", UriKind.Relative));
}

void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
    //error checking...
    TimeSpan ts = DateTime.Now - started;

    throw new NotImplementedException();
}

}