本文整理汇总了C#中System.Progress.Finish方法的典型用法代码示例。如果您正苦于以下问题:C# Progress.Finish方法的具体用法?C# Progress.Finish怎么用?C# Progress.Finish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Progress
的用法示例。
在下文中一共展示了Progress.Finish方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ManageProgress
protected void ManageProgress(BindingSource bindingSource, DoubleBufferedDataGridView grid, FrameType frameType,
int sleepTimer)
{
var progress = new Progress();
progress.SetupAndShow(caller, 0, 0, false, true, waitHandle);
progressSearched = 0;
progressFound = 0;
UpdateGridDelegate gridUpdater = UpdateGrid;
var updateParams = new object[] {bindingSource};
ResortGridDelegate gridSorter = ResortGrid;
var sortParams = new object[] {bindingSource, grid, frameType};
SetButtonDelegate setButton = SetGenerateButton;
try
{
bool alive = true;
while (alive)
{
progress.ShowProgress(progressSearched/(float) progressTotal, progressSearched, progressFound);
if (refreshQueue)
{
caller.Invoke(gridUpdater, updateParams);
refreshQueue = false;
}
if (jobs != null)
{
foreach (Thread job in jobs)
{
if (job != null && job.IsAlive)
{
alive = true;
break;
}
alive = false;
}
}
if (sleepTimer > 0)
Thread.Sleep(sleepTimer);
}
}
catch (ObjectDisposedException)
{
// This keeps the program from crashing when the Time Finder progress box
// is closed from the Windows taskbar.
}
catch (Exception exception)
{
if (exception.Message != "Operation Cancelled")
{
throw;
}
}
finally
{
progress.Finish();
if (jobs != null)
{
foreach (Thread t in jobs)
{
if (t != null)
{
t.Abort();
}
}
}
caller.Invoke(setButton, true);
caller.Invoke(gridSorter, sortParams);
}
}