Skip to content

Commit

Permalink
Fix possible race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowTheAge committed Feb 9, 2022
1 parent 155e7e6 commit 14a7e60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion YAFC/YAFC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<LangVersion>8</LangVersion>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<PlatformTarget>x64</PlatformTarget>
Expand Down
22 changes: 11 additions & 11 deletions YAFCmodel/Model/ProjectPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,31 @@ protected internal override void ThisChanged(bool visualOnly)
// Dont propagate page changes to project
}

public Task<string> ExternalSolve()
{
currentSolvingVersion = actualVersion;
return content.Solve(this);
}

private async void RunSolveJob()
public async Task<string> ExternalSolve()
{
if (!IsSolutionStale())
return modelError;
currentSolvingVersion = actualVersion;
try
{
var error = await content.Solve(this);
await Ui.EnterMainThread();
if (modelError != error)
modelError = error;
contentChanged?.Invoke(false);
return error;
}
finally
{
await Ui.EnterMainThread();
lastSolvedVersion = currentSolvingVersion;
currentSolvingVersion = 0;
CheckSolve();
}
}

private async void RunSolveJob()
{
modelError = await ExternalSolve();
contentChanged?.Invoke(false);
CheckSolve();
}
}

public abstract class ProjectPageContents : ModelObject<ModelObject>
Expand Down

0 comments on commit 14a7e60

Please sign in to comment.