public void Count() { for (int i = 0; i < 100; ++i) { if (i == 71) { OnCount?.Invoke(); } } }
//событие связываем с делегатом, потом запускаем это событие public void Count() { for (int i = 0; i < 100; i++) { if (i == 71) { //OnCount(); OnCount?.Invoke(); } } }
public void startCounter() { for (int i = 0; i < 10; i++) { Console.WriteLine(i + ":noing Happend"); if (i == 5) { OnCount?.Invoke(); } } }
public void AddMoney(object sender) { lock (_lock) { if (sender is IConvertible) { Money += ((IConvertible)sender).ToDouble(null); } } OnCount?.Invoke(Money); Debug.WriteLine("Money{0}", Money); }
/// <summary> /// Coroutine for the counter. Calls the OnCount event each tick and the the ontimerfinished /// when the countdown reaches zero. /// </summary> /// <returns></returns> private IEnumerator TimerCountDown() { counter -= Time.deltaTime; OnCount?.Invoke(Mathf.RoundToInt(counter)); if (counter <= 0) { OnTimerFinished?.Invoke(); yield break; } yield return(null); }
public void Count() { Random rnd = new Random(); int stopPoint = rnd.Next(0, 100); for (int i = 0; i < 100; i++) { if (i == stopPoint) { OnCount?.Invoke(stopPoint); } } }
void Subscribe(Action <int> callback) { _event -= new OnCount(callback); // Avoid re-subscriptions _event += new OnCount(callback); // Subscribe to future values callback(5); // Pass current values }