Skip to content

Commit

Permalink
Major fixes - auto-sleep preventer, stop script execution , Status in…
Browse files Browse the repository at this point in the history
…itialization
  • Loading branch information
LINGARO\jakub.dropia committed Dec 12, 2018
1 parent 0c89840 commit 0ddc365
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions WorkspaceRunner/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public ProcessStatus Status
get { return Settings.Default.ProcessStatus; }
set
{
if (Settings.Default.ProcessStatus == value)
return;

if (value == ProcessStatus.Running)
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
else if (value == ProcessStatus.Stopped)
SetThreadExecutionState(ES_CONTINUOUS);

if (Settings.Default.ProcessStatus == value)
return;

Settings.Default.ProcessStatus = value;

RaisePropertyChanged(nameof(Status));
Expand Down Expand Up @@ -145,6 +145,7 @@ public MainViewModel()
timer.Interval = 2000;
timer.Elapsed += Timer_Elapsed;
timer.Start();
Status = Settings.Default.ProcessStatus;
}
}

Expand Down Expand Up @@ -335,7 +336,7 @@ private void Stop()
if (Status == ProcessStatus.Running)
{
Status = ProcessStatus.Stopping;
LastStopScriptExecutionStatus = RunScript(Settings.Default.StartScriptPath);
LastStopScriptExecutionStatus = RunScript(Settings.Default.StopScriptPath);
if (LastStopScriptExecutionStatus.WasSuccess)
{
Status = ProcessStatus.Stopped;
Expand Down

0 comments on commit 0ddc365

Please sign in to comment.