ForgeNetworkingRemastered
ForgeNetworkingRemastered copied to clipboard
Unified asynchronous task usage
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.
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.