fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public enum State {Starting = 0, Started=1, Stopping=4, Stopped=6};
  6. static bool StartButtonEnabled = false;
  7. static bool StopButtonEnabled = false;
  8. static State current;
  9.  
  10. public static void SetState(State s)
  11. {
  12. current = s;
  13. //Starting = false;
  14. //Started = false;
  15. //Stopping = false;
  16. //Stopped = false;
  17.  
  18. //MainForm.Instance.Invoke(new MethodInvoker(delegate
  19. //{
  20. /*MainForm.Instance.*/StartButtonEnabled = (2 & (int)s) !=0 ;
  21. /*MainForm.Instance.*/StopButtonEnabled = (1 & (int)s) != 0;
  22. //}));
  23. }
  24.  
  25. public static void show() {
  26. Console.WriteLine ("{2}: StartButton {0}, StopButton {1}",StartButtonEnabled ,StopButtonEnabled, current );
  27. }
  28. public static void Main()
  29. {
  30. SetState(State.Starting); show();
  31. SetState(State.Started); show();
  32. SetState(State.Stopping); show();
  33. SetState(State.Stopped); show();
  34. // your code goes here
  35. }
  36. }
Success #stdin #stdout 0.01s 131648KB
stdin
Standard input is empty
stdout
Starting: StartButton False, StopButton False
Started: StartButton False, StopButton True
Stopping: StartButton False, StopButton False
Stopped: StartButton True, StopButton False