public void Update() { if (updateDelegate != null && updateDelegate.GetInvocationList().Length > 0) { updateDelegate.Invoke(); } }
private void InvokeAllLogExceptions(float deltaTime, UpdateDelegate evt) { if (evt != null) { foreach (var @delegate in evt.GetInvocationList()) { try { var del = (UpdateDelegate)@delegate; del.Invoke(deltaTime, this); } catch (Exception ex) { Console.WriteLine(ex); } } Profiler.StartMethod("ExecuteCommandBuffers"); foreach (IEntityCommandBuffer buffer in entityCommandBuffersToExecute) { buffer.Playback(); } entityCommandBuffersToExecute.Clear(); Profiler.EndMethod(); Profiler.StartMethod("DeliverEvents"); EventManager.DeliverEvents(); Profiler.EndMethod(); } }
public Task UpdateAtomicAsync(Func <Task <TDocument> > updateAsync) { if (updateAsync == null) { return(Task.CompletedTask); } _updateDelegateAsync += () => updateAsync(); _documentStore.AfterCommitSuccess <TDocument>(async() => { (var locker, var locked) = await _distributedLock.TryAcquireLockAsync(_lockKey, LockTimeout, LockExpiration); if (!locked) { return; } await using var acquiredLock = locker; TDocument document = null; foreach (var d in _updateDelegateAsync.GetInvocationList()) { document = await((UpdateDelegate)d)(); } document.Identifier ??= IdGenerator.GenerateId(); await SetInternalAsync(document); }); return(Task.CompletedTask); }
public override void Activate(Engine e, Control prevControl) { if (prevControl == null || prevControl is ConfigurationScreen) { // mount bool mountSuccess = e.LoadMount(); spStart.Enabled = mountSuccess && Clicked_NewCampaign?.GetInvocationList().Length > 0; spLoad.Enabled = mountSuccess && Clicked_LoadCampaign?.GetInvocationList().Length > 0; spLaunch.Enabled = mountSuccess && Clicked_LaunchGame?.GetInvocationList().Length > 0; AudioEngine.PlayMusic(AudioGlobals.Music_MainMenu); } }
public Task UpdateAtomicAsync(Func <Task <TDocument> > updateAsync, Func <TDocument, Task> afterUpdateAsync = null) { if (updateAsync == null) { return(Task.CompletedTask); } _updateDelegateAsync += () => updateAsync(); if (afterUpdateAsync != null) { _afterUpdateDelegateAsync += document => afterUpdateAsync(document); } DocumentStore.AfterCommitSuccess <TDocument>(async() => { (var locker, var locked) = await _distributedLock.TryAcquireLockAsync( _options.CacheKey + "_LOCK", TimeSpan.FromMilliseconds(_options.LockTimeout), TimeSpan.FromMilliseconds(_options.LockExpiration)); if (!locked) { return; } await using var acquiredLock = locker; TDocument document = null; foreach (var d in _updateDelegateAsync.GetInvocationList()) { document = await((UpdateDelegate)d)(); } document.Identifier ??= IdGenerator.GenerateId(); await SetInternalAsync(document); if (_afterUpdateDelegateAsync != null) { foreach (var d in _afterUpdateDelegateAsync.GetInvocationList()) { await((AfterUpdateDelegate)d)(document); } } }); return(Task.CompletedTask); }
public Task UpdateAtomicAsync(Func <Task <TDocument> > updateAsync, Func <TDocument, Task> afterUpdateAsync = null, TimeSpan?lockAcquireTimeout = null, TimeSpan?lockExpirationTime = null) { if (updateAsync == null) { return(Task.CompletedTask); } _updateDelegateAsync += () => updateAsync(); if (afterUpdateAsync != null) { _afterUpdateDelegateAsync += document => afterUpdateAsync(document); } _documentStore.AfterCommitSuccess <TDocument>(async() => { var timeout = lockAcquireTimeout ?? DefaultLockTimeout; var expiration = lockExpirationTime ?? DefaultLockExpiration; (var locker, var locked) = await _distributedLock.TryAcquireLockAsync(_lockKey, timeout, expiration); if (!locked) { return; } await using var acquiredLock = locker; TDocument document = null; foreach (var d in _updateDelegateAsync.GetInvocationList()) { document = await((UpdateDelegate)d)(); } document.Identifier ??= IdGenerator.GenerateId(); await SetInternalAsync(document); if (_afterUpdateDelegateAsync != null) { foreach (var d in _afterUpdateDelegateAsync.GetInvocationList()) { await((AfterUpdateDelegate)d)(document); } } }); return(Task.CompletedTask); }