本文整理汇总了C#中IProgress.ReportFormat方法的典型用法代码示例。如果您正苦于以下问题:C# IProgress.ReportFormat方法的具体用法?C# IProgress.ReportFormat怎么用?C# IProgress.ReportFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgress
的用法示例。
在下文中一共展示了IProgress.ReportFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportDirectory
async Task<IEnumerable<Track>> ImportDirectory(string directoryName,
CancellationToken cancellationToken, IProgress<string> progress)
{
if (directoryName == null) throw new ArgumentNullException("directoryName");
if (progress == null) throw new ArgumentNullException("progress");
cancellationToken.ThrowIfCancellationRequested();
messenger.SendToUI(new BeganScanningDirectoryEvent());
progress.ReportFormat("Scanning {0}...", Path.GetFileName(directoryName));
var filenames = Directory
.GetFiles(directoryName, "*.*", SearchOption.AllDirectories)
.Where(loader.IsSupportedFileFormat);
return await ImportAsync(filenames, cancellationToken, progress)
.ContinueWith<IEnumerable<Track>>(OnImportComplete);
}
示例2: ImportAsync
public async Task<IEnumerable<Track>> ImportAsync(string filename,
CancellationToken cancellationToken, IProgress<string> progress)
{
if (filename == null) throw new ArgumentNullException("filename");
cancellationToken.ThrowIfCancellationRequested();
if (IsDirectory(filename))
return await ImportDirectory(filename, cancellationToken, progress);
if (!loader.IsSupportedFileFormat(filename))
return Enumerable.Empty<Track>();
progress.ReportFormat("Loading {0}", Path.GetFileName(filename));
Track track;
if (TryGetTrack(filename, out track))
return new[] { track };
track = await loader.LoadAsync(filename);
await storage.AddTrackAsync(track);
tracks.Add(track.Id, track);
messenger.SendToUI(new TrackAddedToLibraryEvent(track));
return new[] { track };
}