我创建了一个带有进度覆盖的自定义用户控件,以获得像动画一样的加载屏幕。通过 Progress.Show() 和 Progress.Hide() 访问。当我从外部 API 获取数据时,如何使用它们?
当你做SomeWebClient.DownloadDataAsync()
时,它有一个进度变化的事件,你可以像这样使用:
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);
}