本文整理匯總了C#中System.Progress.Reset方法的典型用法代碼示例。如果您正苦於以下問題:C# Progress.Reset方法的具體用法?C# Progress.Reset怎麽用?C# Progress.Reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Progress
的用法示例。
在下文中一共展示了Progress.Reset方法的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();
//.........這裏部分代碼省略.........