Skip to content

Conversation

11EJDE11
Copy link
Contributor

@11EJDE11 11EJDE11 commented Oct 2, 2025

Tunnel refresh now reuses existing objects to preserve the PingInMs - this should stop pings changing to unknown in game lobbies.
Also prevents multiple refreshes running at once.

Prevent multiple refreshes running at same time.
Prevent duplicate tunnels.
Copy link

github-actions bot commented Oct 2, 2025

Nightly build for this pull request:

  • artifacts.zip
    This comment is automatic and is meant to allow guests to get latest automatic builds without registering. It is updated on every successful build.

@SadPencil SadPencil requested a review from Copilot October 4, 2025 05:36
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Retains existing tunnel objects during refresh to preserve PingInMs values and prevents concurrent refresh operations.

  • Adds a refresh lock/flag to avoid overlapping tunnel refreshes.
  • Merges refreshed tunnel data into existing objects via new UpdateFrom method while filtering duplicates.
  • Adjusts ping initiation logic and introduces duplicate suppression using a HashSet.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
DXMainClient/Domain/Multiplayer/CnCNet/TunnelHandler.cs Adds refresh concurrency guard, merges tunnel lists preserving PingInMs, removes duplicates, and updates ping invocation logic.
DXMainClient/Domain/Multiplayer/CnCNet/CnCNetTunnel.cs Introduces UpdateFrom method to selectively update tunnel metadata while retaining ping/state.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 91 to 105
Task.Factory.StartNew(() =>
{
List<CnCNetTunnel> tunnels = RefreshTunnels();
wm.AddCallback(new Action<List<CnCNetTunnel>>(HandleRefreshedTunnels), tunnels);
try
{
List<CnCNetTunnel> tunnels = RefreshTunnels();
wm.AddCallback(new Action<List<CnCNetTunnel>>(HandleRefreshedTunnels), tunnels);
}
finally
{
lock (_refreshLock)
{
_refreshInProgress = false;
}
}
});
Copy link
Preview

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Task.Factory.StartNew without specifying TaskScheduler.Default can run this work on the current (UI) synchronization context, defeating the intent of making the refresh asynchronous and potentially freezing the UI. Replace with Task.Run(...) or specify TaskScheduler.Default: Task.Factory.StartNew(() => { ... }, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants