2009-06-11 68 views
1

我想在Silverlight 3應用程序中添加某種「連接質量」指示器,以便讓用戶瞭解其連接速度。這可能是一個變成紅色,黃色或綠色的圖標,以提供用戶應該期望的性能的基本概念。在Silverlight中測量連接速度的好方法是什麼?Silverlight中的連接速度測試

回答

2

我會開始一個Web請求,然後時間花了多長時間。例如:

public partial class Page:UserControl { DateTime started;

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(); 
} 

}