Skip to content

Commit

Permalink
properly wait if replay file is busy
Browse files Browse the repository at this point in the history
  • Loading branch information
poma committed Mar 17, 2016
1 parent ce86d79 commit 2dfb671
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions StatsDisplay/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.4.1")]
[assembly: AssemblyFileVersion("0.4.1")]
[assembly: AssemblyVersion("0.4.2")]
[assembly: AssemblyFileVersion("0.4.2")]
4 changes: 2 additions & 2 deletions StatsDisplay/Settings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ private void ProcessLobbyFile(string path)
currentWindow.Show();
}

private void ProcessRejoinFile(string path)
private async void ProcessRejoinFile(string path)
{
FileProcessor.ProcessRejoin(path, App.game);
await FileProcessor.ProcessRejoin(path, App.game);
currentWindow?.Close();
currentWindow = new FullStatsWindow();
}
Expand Down
6 changes: 3 additions & 3 deletions StatsFetcher/FileProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static async Task FetchProfiles(Game game)
game.TriggerPropertyChanged();
}

public static void ProcessRejoin(string path, Game game)
public static async Task ProcessRejoin(string path, Game game)
{
var tmpPath = Path.GetTempFileName();

Expand All @@ -39,10 +39,10 @@ public static void ProcessRejoin(string path, Game game)
break;
}
catch (IOException e) {
File.AppendAllText("log.txt", $"[{DateTime.Now}] Replay copy error ({i}): {e}\n\n");
if (i < 4) {
System.Threading.Thread.Sleep(1000); // todo: don't block UI thread
await Task.Delay(1000);
} else {
File.AppendAllText("log.txt", $"[{DateTime.Now}] Replay copy error ({i}): {e}\n\n");
throw new ApplicationException("Can't access replay file", e);
}
}
Expand Down

0 comments on commit 2dfb671

Please sign in to comment.