ForgeNetworkingRemastered icon indicating copy to clipboard operation
ForgeNetworkingRemastered copied to clipboard

Unified asynchronous task usage

Open ilookha opened this issue 6 years ago • 1 comments

When debugging issue #322, I noticed a bit of inconsistency in task/thread management, especially when it comes to joining all background threads on shutdown/session reset. This pull request is aimed to improve this situation.

  • use BeardedManStudios.Threading.Task for all task needs, instead of System.Threading directly;
  • added thread join support: BMS.Threading.Task.WaitAll();
  • in any infinite loops, use NetWorker.IsActiveSession checks instead of just IsBound, to cover EndingSession requests;
  • NetWorker.EndSession now uses Task.WaitAll instead of an arbitrary 1s wait;
  • fixed NetworkingPlayer.BackgroundServerPing to use non-zero wait time and actually ping the server.

ilookha avatar Oct 04 '19 16:10 ilookha

Going to require further testing on this to test whether this to verify there are no issues introduced if we were to merge this in.

Crazy8ball avatar Oct 24 '19 06:10 Crazy8ball