@@ -9,15 +9,20 @@ namespace TryCSharp.Tools.Cui
99 /// </summary>
1010 public class CuiAppProcessExecutor : IExecutor
1111 {
12- public string StartLogMessage { get ; set ; }
13- public string EndLogMessage { get ; set ; }
12+ /// <summary>
13+ /// 開始ログ
14+ /// </summary>
15+ private string StartLogMessage { get ; } = "================== START ==================" ;
1416
15- public CuiAppProcessExecutor ( )
16- {
17- StartLogMessage = "================== START ==================" ;
18- EndLogMessage = "================== END ==================" ;
19- }
17+ /// <summary>
18+ /// 終了ログ
19+ /// </summary>
20+ private string EndLogMessage { get ; } = "================== END ==================" ;
2021
22+ /// <summary>
23+ /// 実行します。
24+ /// </summary>
25+ /// <param name="target">実行可能なもの</param>
2126 public void Execute ( IExecutable target )
2227 {
2328 if ( target == null )
@@ -27,9 +32,34 @@ public void Execute(IExecutable target)
2732
2833 using ( new TimeTracer ( ) )
2934 {
30- Output . WriteLine ( StartLogMessage ) ;
35+ Output . WriteLine ( this . StartLogMessage ) ;
3136 target . Execute ( ) ;
32- Output . WriteLine ( EndLogMessage ) ;
37+ Output . WriteLine ( this . EndLogMessage ) ;
38+ }
39+ }
40+
41+ /// <summary>
42+ /// 非同期実行します。
43+ /// </summary>
44+ /// <param name="target">実行可能なもの</param>
45+ public void Execute ( IAsyncExecutable target )
46+ {
47+ if ( target == null )
48+ {
49+ throw new ArgumentNullException ( nameof ( target ) ) ;
50+ }
51+
52+ using ( new TimeTracer ( ) )
53+ {
54+ Output . WriteLine ( this . StartLogMessage ) ;
55+
56+ var success = target . Execute ( ) . Wait ( TimeSpan . FromSeconds ( 15 ) ) ;
57+ if ( ! success )
58+ {
59+ Output . WriteLine ( "time out....." ) ;
60+ }
61+
62+ Output . WriteLine ( this . EndLogMessage ) ;
3363 }
3464 }
3565 }
@@ -40,17 +70,13 @@ internal class TimeTracer : IDisposable
4070
4171 public TimeTracer ( )
4272 {
43- _watch = Stopwatch . StartNew ( ) ;
73+ this . _watch = Stopwatch . StartNew ( ) ;
4474 }
4575
46- #region IDisposable メンバー
47-
4876 public void Dispose ( )
4977 {
50- _watch . Stop ( ) ;
51- Output . WriteLine ( "処理時間: {0}" , _watch . Elapsed ) ;
78+ this . _watch . Stop ( ) ;
79+ Output . WriteLine ( "Elapsed Time: {0}" , this . _watch . Elapsed ) ;
5280 }
53-
54- #endregion
5581 }
5682}
0 commit comments