我创建了一个带有进度叠加层的自定义用户控件,以获得像动画一样的加载屏幕。通过Progress.Show()和Progress.Hide()访问。当我从外部api获取数据时如何使用这些?
答案 0 :(得分:0)
当您执行SomeWebClient.DownloadDataAsync()
时,它有一个progress changed event,您可以这样使用:
private static void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e)
{
// Displays the operation identifier, and the transfer progress.
Console.WriteLine("{0} downloaded {1} of {2} bytes. {3} % complete...",
(string)e.UserState,
e.BytesReceived,
e.TotalBytesToReceive,
e.ProgressPercentage);
}