Skip to content

Commit

Permalink
Merge pull request gibbed#73 from xPaw/patch-2.
Browse files Browse the repository at this point in the history
Reduce UI freezes when opening the app
  • Loading branch information
gibbed authored May 27, 2018
2 parents b4a0cc7 + 3dac4e2 commit 16c552e
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions SAM.Picker/GamePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private void OnAppDataChanged(APITypes.AppDataChanged param)

game.Name = this._SteamClient.SteamApps001.GetAppData(game.Id, "name");
this.AddGameToLogoQueue(game);
this.DownloadNextLogo();
}
}

Expand All @@ -111,20 +112,16 @@ private void DoDownloadList(object sender, DoWorkEventArgs e)
pairs.Add(new KeyValuePair<uint, string>((uint)nodes.Current.ValueAsLong, type));
}
}
e.Result = pairs;

foreach (var kv in pairs)
{
this.AddGame(kv.Key, kv.Value);
}
}

private void OnDownloadList(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error == null && e.Cancelled == false)
{
var pairs = (List<KeyValuePair<uint, string>>)e.Result;
foreach (var kv in pairs)
{
this.AddGame(kv.Key, kv.Value);
}
}
else
if (e.Error != null || e.Cancelled)
{
this.AddDefaultGames();
//MessageBox.Show(e.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Expand Down Expand Up @@ -157,15 +154,10 @@ private void RefreshGames()
continue;
}
this._FilteredGames.Add(info);
this.AddGameToLogoQueue(info);
}

this._GameListView.BeginUpdate();
this._GameListView.VirtualListSize = this._FilteredGames.Count;
if (this._FilteredGames.Count > 0)
{
this._GameListView.RedrawItems(0, this._FilteredGames.Count - 1, true);
}
this._GameListView.EndUpdate();
this._PickerStatusLabel.Text = string.Format(
"Displaying {0} games. Total {1} games.",
this._GameListView.Items.Count,
Expand Down Expand Up @@ -270,7 +262,6 @@ private void AddGameToLogoQueue(GameInfo info)
{
this._LogosAttempted.Add(logo);
this._LogoQueue.Enqueue(info);
this.DownloadNextLogo();
}
}

Expand All @@ -295,7 +286,6 @@ private void AddGame(uint id, string type)
info.Name = this._SteamClient.SteamApps001.GetAppData(info.Id, "name");

this._Games.Add(id, info);
this.AddGameToLogoQueue(info);
}

private void AddGames()
Expand Down

0 comments on commit 16c552e

Please sign in to comment.