示例#1
0
 public void Count()
 {
     for (int i = 0; i < 100; ++i)
     {
         if (i == 71)
         {
             OnCount?.Invoke();
         }
     }
 }
示例#2
0
        //событие связываем с делегатом, потом запускаем это событие

        public void Count()
        {
            for (int i = 0; i < 100; i++)
            {
                if (i == 71)
                {
                    //OnCount();
                    OnCount?.Invoke();
                }
            }
        }
示例#3
0
 public void startCounter()
 {
     for (int i = 0; i < 10; i++)
     {
         Console.WriteLine(i + ":noing Happend");
         if (i == 5)
         {
             OnCount?.Invoke();
         }
     }
 }
示例#4
0
 public void AddMoney(object sender)
 {
     lock (_lock)
     {
         if (sender is IConvertible)
         {
             Money += ((IConvertible)sender).ToDouble(null);
         }
     }
     OnCount?.Invoke(Money);
     Debug.WriteLine("Money{0}", Money);
 }
示例#5
0
        /// <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);
        }
示例#6
0
        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);
                }
            }
        }
示例#7
0
 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
 }