本文整理汇总了C#中System.Progress.ToObservable方法的典型用法代码示例。如果您正苦于以下问题:C# Progress.ToObservable方法的具体用法?C# Progress.ToObservable怎么用?C# Progress.ToObservable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Progress
的用法示例。
在下文中一共展示了Progress.ToObservable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Upload
async public Task<FFile> Upload(int fFileID)
{
while (IsNetworkOk == false)
{
await Task.Delay(TimeSpan.FromSeconds(3));
}
var file = fFileLogic.GetForSure(fFileID);
if (file == null)
{
fFileLogic.DoUpdate(fFileID, f =>
{
f.Status = FFileStatus.NonExisting;
});
}
else
{
var isExisted = fFileLogic.CheckExistHashCode(ExistFile, fFileID);
if (isExisted)
{
file = fFileLogic.DoUpdate(fFileID, file1 =>
{
if (file1.Status == FFileStatus.New)
{
file1.Status = FFileStatus.Existing;
file1.ProcessingStatus = null;
}
});
}
else
{
var progress = new Progress<UploadProgressChangedEventArgs>();
progress.ToObservable()
.DistinctUntilChanged(r => (int)r.EventArgs.UploadPercentage() / 5)
.Subscribe(r =>
{
FlickrLogic.UploadEventList.Add(new Notice()
{
Type = NoticeType.Upload,
JobDone = r.EventArgs.BytesSent,
JobTotal = r.EventArgs.TotalBytesToSend,
Percentage = r.EventArgs.UploadPercentage(),
FullPath = file.Path,
Note = "Uploading",
});
})
;
var photoID = await flickr.UploadPicture(file.Path, tags: file.GetHashCodeTag(), progress: progress);
if (string.IsNullOrEmpty(photoID))
{ }
else
{
file = fFileLogic.DoUpdate(fFileID, file1 =>
{
file1.PhotoID = photoID;
file1.Status = FFileStatus.Uploaded_NoSet;
file1.UserID = Flickr.User.UserId;
});
UpdateSets(file.Id);
FlickrLogic.Log(file.Path, NoticeType.UploadDone, "Uploaded");
}
}
}
return file;
}