本文整理汇总了C#中ActionableProgress类的典型用法代码示例。如果您正苦于以下问题:C# ActionableProgress类的具体用法?C# ActionableProgress怎么用?C# ActionableProgress使用的例子? 这里精选的类代码示例或许可以为您提供帮助。
示例1: Run
public async Task Run(IProgress
progress, CancellationToken cancellationToken)
{
var users = _userManager.Users
.DistinctBy(ChannelDownloadScheduledTask.GetUserDistinctValue)
.Select(i => i.Id.ToString("N"))
.ToList();
var numComplete = 0;
foreach (var user in users)
{
double percentPerUser = 1;
percentPerUser /= users.Count;
var startingPercent = numComplete * percentPerUser * 100;
var innerProgress = new ActionableProgress();
innerProgress.RegisterAction(p => progress.Report(startingPercent + (percentPerUser * p)));
await DownloadContent(user, cancellationToken, innerProgress).ConfigureAwait(false);
numComplete++;
double percent = numComplete;
percent /= users.Count;
progress.Report(percent * 100);
}
progress.Report(100);
}
原文链接:http://www.jxszl.com/biancheng/C/556452.html