From 0450925f66ddded2dc51b21884a9bb9d98aa2342 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 26 七月 2024 15:54:46 +0800 Subject: [PATCH] 添加计时功能 --- SimuTools/FrmMain.cs | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/SimuTools/FrmMain.cs b/SimuTools/FrmMain.cs index d15b5a0..76264a9 100644 --- a/SimuTools/FrmMain.cs +++ b/SimuTools/FrmMain.cs @@ -1,6 +1,7 @@ 锘縰sing SimuTools.Domain; using SimuTools.Tools; using System; +using System.Diagnostics; using System.IO; using System.Windows.Forms; @@ -124,11 +125,14 @@ this.btnRun.Enabled = false; LogOut.Info("寮�濮嬭繍琛� >>"); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); Tools.Handle.Run(new Args(serviceName, terrainFile, buildingFile, waterPath, flowPath, outPath)); + stopWatch.Stop(); this.btnRun.Enabled = true; LogOut.Info("杩愯缁撴潫 <<"); - MessageBox.Show("杩愯缁撴潫锛�", "鎻愮ず", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("杩愯缁撴潫锛乗n鑰楁椂锛�" + GetSeconds(stopWatch.ElapsedMilliseconds) + " 绉�", "鎻愮ず", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { @@ -142,5 +146,10 @@ { MessageBox.Show(message, "鎻愮ず", MessageBoxButtons.OK, MessageBoxIcon.Error); } + + private string GetSeconds(long milliseconds) + { + return (milliseconds / 1000.0).ToString(); + } } } -- Gitblit v1.9.3