@@ -11,6 +11,9 @@ namespace XmrStakBootstrap.Core.Job.Miner
1111{
1212 public class MinerRunnerMenuJob : IJob
1313 {
14+ private const bool Continue = true ;
15+ private const bool Terminate = false ;
16+
1417 [ Dependency ]
1518 public IFinalizer Finalizer { get ; set ; }
1619
@@ -57,51 +60,65 @@ public void Execute()
5760 . Create ( ( ) =>
5861 {
5962 Console . Clear ( ) ;
60- return true ;
61- } )
62- . AddConditionalOption ( @"Start/restart miners" , CanRun , ( ) =>
63- {
64- Console . Clear ( ) ;
65- if ( KillMiners ( ) && RunConfigurationModel . MinerStartDelay > 0 )
66- {
67- Console . WriteLine ( $@ "Waiting { RunConfigurationModel . MinerStartDelay } second(s) before starting new miner(s).") ;
68- Thread . Sleep ( RunConfigurationModel . MinerStartDelay * 1000 ) ;
69- }
70- Finalizer . DoFinalize ( ) ;
71- Runner . Run ( ) ; //TODO: issue #1
72- return false ;
73- } )
74- . AddEnabledOption ( @"Change solution" , ( ) =>
75- {
76- SelectSolution ( ) ; //TODO: issue #1
77- Console . Clear ( ) ;
78- return true ;
79- } )
80- . AddEnabledOption ( @"Change workload" , ( ) =>
81- {
82- SelectWorkload ( ) ; //TODO: issue #1
83- Console . Clear ( ) ;
84- return true ;
85- } )
86- . AddEnabledOption ( @"Exit" , ( ) =>
87- {
88- Console . Clear ( ) ;
89- Finalizer . DoFinalize ( ) ;
90- Environment . Exit ( 0 ) ;
91- return false ;
92- } )
93- . AddEnabledOption ( @"Exit & terminate miners" , ( ) =>
94- {
95- Console . Clear ( ) ;
96- KillMiners ( ) ;
97- Finalizer . DoFinalize ( ) ;
98- Environment . Exit ( 0 ) ;
99- return false ;
63+ return Continue ;
10064 } )
65+ . AddConditionalOption ( @"Start/restart miners" , CanRun , MenuOptionStartMiners )
66+ . AddEnabledOption ( @"Change solution" , MenuOptionChangeSolution )
67+ . AddEnabledOption ( @"Change workload" , MenuOptionChangeWorkload )
68+ . AddEnabledOption ( @"Exit" , MenuOptionExit )
69+ . AddEnabledOption ( @"Exit & terminate miners" , MenuOptionExitAndTerminateMiners )
10170 . Execute ( ) ;
10271 }
10372 }
10473
74+ #region Menu options
75+
76+ private bool MenuOptionStartMiners ( )
77+ {
78+ Console . Clear ( ) ;
79+ if ( KillMiners ( ) && RunConfigurationModel . MinerStartDelay > 0 )
80+ {
81+ Console . WriteLine ( $@ "Waiting { RunConfigurationModel . MinerStartDelay } second(s) before starting new miner(s).") ;
82+ Thread . Sleep ( RunConfigurationModel . MinerStartDelay * 1000 ) ;
83+ }
84+ Finalizer . DoFinalize ( ) ;
85+ Runner . Run ( ) ; //TODO: issue #1
86+ return Terminate ;
87+ }
88+
89+ private bool MenuOptionChangeSolution ( )
90+ {
91+ SelectSolution ( ) ; //TODO: issue #1
92+ Console . Clear ( ) ;
93+ return Continue ;
94+ }
95+
96+ private bool MenuOptionChangeWorkload ( )
97+ {
98+ SelectWorkload ( ) ; //TODO: issue #1
99+ Console . Clear ( ) ;
100+ return Continue ;
101+ }
102+
103+ private bool MenuOptionExit ( )
104+ {
105+ Console . Clear ( ) ;
106+ Finalizer . DoFinalize ( ) ;
107+ Environment . Exit ( 0 ) ;
108+ return Terminate ;
109+ }
110+
111+ private bool MenuOptionExitAndTerminateMiners ( )
112+ {
113+ Console . Clear ( ) ;
114+ KillMiners ( ) ;
115+ Finalizer . DoFinalize ( ) ;
116+ Environment . Exit ( 0 ) ;
117+ return Terminate ;
118+ }
119+
120+ #endregion
121+
105122 private static void ColorConsole ( ConsoleColor color , Action action )
106123 {
107124 using ( ConsoleColorClosure . ForegroundColor ( color ) ) action ( ) ;
0 commit comments