本文整理汇总了C#中ProgressBar.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# ProgressBar.ShowDialog方法的具体用法?C# ProgressBar.ShowDialog怎么用?C# ProgressBar.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.ShowDialog方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegenerateHeightmap
private void RegenerateHeightmap(object sender, RoutedEventArgs e)
{
// stop rendering
terrainRenderingPreview.DeactivateRendering = true;
int resolution = GetResolution();
heightmapData = new float[resolution, resolution];
// predeclare progress bar
ProgressBar progressBar = null;
var mainWindowDispatcher = Dispatcher;
long heightmapGentimeMS = 0;
string json = SerializeSettingsToJSON(); // access to stuff from this thread - not possible in Task
Task generateTask = new Task(() =>
{
try
{
Stopwatch sw = new Stopwatch();
sw.Start();
new MstBasedHeightmap.GeneratorPipeline(json).Execute(heightmapData);
heightmapGentimeMS = sw.ElapsedMilliseconds;
}
catch
{
System.Diagnostics.Debugger.Break();
}
});
generateTask.Start();
progressBar = new ProgressBar(() => generateTask.IsCompleted ||generateTask.IsCanceled || generateTask.IsFaulted);
progressBar.TaskDescription.Content = "Generating Heightmap ...";
progressBar.ShowDialog();
// upload to graphics cards (needs to stay in mainthread!
terrainRenderingPreview.LoadNewHeightMap(heightmapData, resolution / (float)MAP_SIZE);
// continue rendering
terrainRenderingPreview.DeactivateRendering = false;
// display timings
MessageBox.Show("Heightmap Computation Time:\t " + heightmapGentimeMS + "ms", "Done!");
}