public void Tick() { Assert.That(_isAsync); if (!_asyncQueue.IsEmpty()) { // Cache the callback list to allow handlers to be added from within callbacks using (var block = DisposeBlock.Spawn()) { var subscriptions = block.SpawnList <SignalSubscription>(); subscriptions.AddRange(_subscriptions); // Cache the signals so that if the signal is fired again inside the handler that it // is not executed until next frame var signals = block.SpawnList <object>(); signals.AddRange(_asyncQueue); _asyncQueue.Clear(); for (int i = 0; i < signals.Count; i++) { FireInternal(subscriptions, signals[i]); } } } }
public void Fire(object signal) { Assert.That(signal.GetType().DerivesFromOrEqual(_bindingId.Type)); if (_isAsync) { _asyncQueue.Add(signal); } else { // Cache the callback list to allow handlers to be added from within callbacks using (var block = DisposeBlock.Spawn()) { var subscriptions = block.SpawnList <SignalSubscription>(); subscriptions.AddRange(_subscriptions); FireInternal(subscriptions, signal); } } }