SyncStopwatch
SyncStopwatch provides an efficient way to synchronize a stopwatch between server and clients.
private readonly SyncStopwatch _timePassed = new()// All of the actions below are automatically synchronized.
/* Starts the stopwatch while optionally sending a stop
* message first if stopwatch was already running.
* If the stopwatch was previously running the time passed
* would be reset. */
/* This would invoke callbacks indicating a stopwatch
* had stopped, then started again. */
_timePassed.StartStopwatch(true);
/* Pauses the stopwatch and optionally sends the current
* timer value as it is on the server. */
_timePassed.PauseStopwatch(false);
// Unpauses the current stopwatch.
_timePassed.UnpauseStopwatch();
/* Ends the Stopwatch while optionally sends the
* current value to clients, as it was during the stop. */
_timePassed.StopStopwatch(false);Last updated