本文整理汇总了C#中System.Progress.Increment方法的典型用法代码示例。如果您正苦于以下问题:C# Progress.Increment方法的具体用法?C# Progress.Increment怎么用?C# Progress.Increment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Progress
的用法示例。
在下文中一共展示了Progress.Increment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateWithWorker
public void UpdateWithWorker(BackgroundWorker worker)
{
Progress progress1 = new Progress(0, 3);
Progress progress2 = new Progress();
int bytesRead;
byte[] buffer = new byte[4096];
worker.ReportProgress(DisplayProgress1, progress1);
// Download File List
using (WebClient client = new WebClient())
{
worker.ReportProgress(DisplayProgressText1, "Downloading File List ...");
worker.ReportProgress(DisplayProgressText2, String.Empty);
string files;
try
{
files = client.DownloadString(FileListUrl);
}
catch (Exception e)
{
throw new ApplicationException("Could not download file-list.\nDetails: " + e.Message, e);
}
progress1.Increment();
worker.ReportProgress(DisplayProgress1, progress1);
worker.ReportProgress(DisplayProgressText1, "Validating File List ...");
worker.ReportProgress(DisplayProgressText2, String.Empty);
Items.Clear();
StringReader reader = new StringReader(files);
string line = reader.ReadLine();
while (line != null)
{
string[] fragments = line.Split('\t');
UpdateItem item = new UpdateItem(m_RootPath);
if (fragments.Length >= 1)
{
item.FileName = fragments[0];
if (String.Equals(Path.GetFullPath(item.FileName), Path.GetFullPath(Application.ExecutablePath), StringComparison.InvariantCultureIgnoreCase))
{
item.TargetFileName = item.FileName + ".tmp";
SelfUpdateDetected = true;
SelfUpdateItem = item;
}
if (String.IsNullOrEmpty(item.FileName)) continue;
m_Items.Add(item);
}
if (fragments.Length >= 2)
{
item.Hash = fragments[1];
}
line = reader.ReadLine();
}
progress1.Increment();
worker.ReportProgress(DisplayProgress1, progress1);
if (worker.CancellationPending) return;
progress2.Reset(0, Items.Count);
worker.ReportProgress(DisplayProgress2, progress2);
worker.ReportProgress(DisplayProgressText1, "Validating Files ...");
Crc32Processor processor = new Crc32Processor();
foreach (UpdateItem item in Items)
{
if (worker.CancellationPending) return;
worker.ReportProgress(DisplayProgressText2, item.FullName);
if (File.Exists(item.FullName) == false)
{
item.CheckStatus = UpdateCheckStatus.NotExisiting;
item.IsUpdateRequired = true;
}
else
{
using (FileStream fs = File.OpenRead(item.FullName))
{
while (true)
{
bytesRead = fs.Read(buffer, 0, buffer.Length);
processor.Process(buffer, 0, bytesRead);
if (bytesRead != buffer.Length) break;
}
}
if (item.Hash != processor.Current.ToString("X8"))
{
item.CheckStatus = UpdateCheckStatus.HashMismatch;
item.IsUpdateRequired = true;
}
else
{
item.CheckStatus = UpdateCheckStatus.Ok;
}
processor.Reset();
}
progress2.Increment();
worker.ReportProgress(DisplayProgress2, progress2);
}
progress1.Increment();
//.........这里部分代码省略.........