private void OnGameObjectIDRequested(GameObjectIDRequestEventArgs args) { if (args == null) { return; } ExecuteRemoteCommand(() => args.Value = _serviceClient.GetNewObjectID()); args.WaitHandle.Set(); }
public int?GetNewObjectID() { var args = new GameObjectIDRequestEventArgs( _appContext, _appContext.CurrentGame); ClientEvents.GameObjectIDRequested.Publish(args); var waitStart = DateTime.Now; var timeout = TimeSpan.FromSeconds(5); while (!args.WaitHandle.WaitOne(timeout)) { if ((DateTime.Now - waitStart) > timeout) { break; } } return(args.Value); }