本文整理汇总了C#中IProgress.SetDescription方法的典型用法代码示例。如果您正苦于以下问题:C# IProgress.SetDescription方法的具体用法?C# IProgress.SetDescription怎么用?C# IProgress.SetDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgress
的用法示例。
在下文中一共展示了IProgress.SetDescription方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public void Execute(IProgress progress) {
for (int i = 0; i < documentsToLoad.Length; i++) {
progress.ThrowIfCancellationRequested();
var f = documentsToLoad[i];
progress.SetTotalProgress(i);
progress.SetDescription(GetDescription(f.Info));
Load(f);
}
progress.SetTotalProgress(documentsToLoad.Length);
}
示例2: foreach
unsafe void IProgressTask.Execute(IProgress progress) {
this.progress = progress;
if (infos.Length == 0)
return;
uint maxSize = infos.Max(a => a.Size);
var buf = new byte[maxSize];
byte[] buf2 = null;
foreach (var info in infos) {
progress.ThrowIfCancellationRequested();
progress.SetDescription(Path.GetFileName(info.Filename));
ProcessMemoryUtils.ReadMemory(info.ProcessHandle, info.Address, buf, 0, (int)info.Size);
progress.ThrowIfCancellationRequested();
currentProgress++;
progress.SetTotalProgress(currentProgress);
byte[] data = buf;
int dataSize = (int)info.Size;
if (info.MemoryLayout) {
if (buf2 == null)
buf2 = new byte[buf.Length];
data = buf2;
progress.ThrowIfCancellationRequested();
Array.Clear(buf2, 0, dataSize);
WritePEFile(buf, buf2, dataSize, out dataSize);
}
var file = File.Create(info.Filename);
try {
file.Write(data, 0, dataSize);
currentProgress++;
progress.SetTotalProgress(currentProgress);
}
catch {
file.Dispose();
try { File.Delete(info.Filename); }
catch { }
throw;
}
finally {
file.Dispose();
}
}
}
示例3: Execute
public void Execute(IProgress progress) {
progress.SetDescription(filename);
var file = File.Create(filename);
try {
var buf = new byte[BUF_SIZE];
ulong offs = start;
long currentProgress = 0;
while (offs <= end) {
progress.ThrowIfCancellationRequested();
progress.SetTotalProgress(currentProgress);
currentProgress++;
ulong left = end - start + 1;
if (left == 0)
left = ulong.MaxValue;
int size = left > (ulong)buf.Length ? buf.Length : (int)left;
doc.Read(offs, buf, 0, size);
file.Write(buf, 0, size);
offs += (ulong)size;
if (offs == 0)
break;
}
progress.SetTotalProgress(currentProgress);
}
catch {
file.Dispose();
try { File.Delete(filename); }
catch { }
throw;
}
finally {
file.Dispose();
}
}
示例4: Execute
public void Execute(IProgress progress) {
var buf = new byte[64 * 1024];
for (int i = 0; i < fileInfos.Length; i++) {
progress.ThrowIfCancellationRequested();
var info = fileInfos[i];
progress.SetDescription(info.Item2);
progress.SetTotalProgress(i);
Directory.CreateDirectory(Path.GetDirectoryName(info.Item2));
var file = File.Create(info.Item2);
try {
info.Item1.Position = 0;
for (;;) {
int len = info.Item1.Read(buf, 0, buf.Length);
if (len <= 0) {
if (info.Item1.Position != info.Item1.Length)
throw new Exception("Could not read all bytes");
break;
}
file.Write(buf, 0, len);
}
}
catch {
file.Dispose();
try { File.Delete(info.Item2); }
catch { }
throw;
}
finally {
file.Dispose();
}
}
progress.SetTotalProgress(fileInfos.Length);
}
示例5: Execute
public void Execute(IProgress progress) {
progress.SetDescription(filename);
var file = File.Create(filename);
try {
var buf = new byte[BUF_SIZE];
var pos = span.Start;
long currentProgress = 0;
while (pos < span.End) {
progress.ThrowIfCancellationRequested();
progress.SetTotalProgress(currentProgress);
currentProgress++;
ulong left = (span.End - pos).ToUInt64();
if (left == 0)
left = ulong.MaxValue;
int size = left > (ulong)buf.Length ? buf.Length : (int)left;
buffer.ReadBytes(pos, buf, 0, size);
file.Write(buf, 0, size);
pos += (ulong)size;
}
progress.SetTotalProgress(currentProgress);
}
catch {
file.Dispose();
try { File.Delete(filename); }
catch { }
throw;
}
finally {
file.Dispose();
}
}