忙了好一陣子,終於又有空閒時間記錄筆記,
這次剛好有這個需求,主要是寫了一支外部發起Easy Flow GP表單程式
偶爾需要手動啟動此程式,特地弄了一個頁面供USER手動
其中最主要使用到的C#程式如下
其中有用到兩個System.Diagnostics的類別 Process 、 Stopwatch 。
最後回傳執行時間顯示於畫面上。
這次剛好有這個需求,主要是寫了一支外部發起Easy Flow GP表單程式
偶爾需要手動啟動此程式,特地弄了一個頁面供USER手動
其中最主要使用到的C#程式如下
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); //引用stopwatch物件
sw.Reset();//碼表歸零
sw.Start();//碼表開始計時
Process exeProcess = new Process();
exeProcess.StartInfo.FileName = @"C:\xxxx\xxxxx\xxxxxxxx.exe";
//執行程式路徑
exeProcess.StartInfo.Arguments = strArg; //傳入參數
exeProcess.Start();
exeProcess.WaitForExit();//等待執行程式結束
if (exeProcess != null)
{
exeProcess.Close();
exeProcess.Dispose();
exeProcess = null;
sw.Stop();//碼錶停止
}
//印出所花費的總豪秒數
string result1 = sw.Elapsed.TotalMilliseconds.ToString();
return result1;
其中有用到兩個System.Diagnostics的類別 Process 、 Stopwatch 。
最後回傳執行時間顯示於畫面上。
留言
張貼留言