Esempio n. 1
0
        /// <summary>
        /// Start a "session" of Pulse events.
        /// </summary>
        /// <param name="intervalInMilliSecs">
        /// Interval (in milliseconds) between each Pulse event
        /// </param>
        /// <param name="noOfPulses">
        /// Number of Pulse events generated in this session
        /// </param>
        public async Task Start(int intervalInMilliSecs, int noOfPulses = 1000)
        {
            while (noOfPulses > 0)
            {
                await Task.Delay(intervalInMilliSecs);

                Pulse?.Invoke();
                noOfPulses--;

                if (noOfPulses == 0)
                {
                    LastPulse?.Invoke();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Start a "session" of Pulse events.
        /// </summary>
        /// <param name="intervalInMilliSecs">
        /// Interval (in milliseconds) between each Pulse event
        /// </param>
        /// <param name="noOfPulses">
        /// Number of Pulse events to be generated in this session
        /// </param>
        /// <returns></returns>
        public async Task Start(int intervalInMilliSecs, int noOfPulses = 1000)
        {
            int pulseCount = 0;

            while (noOfPulses > pulseCount)
            {
                await Task.Delay(intervalInMilliSecs);

                pulseCount++;
                Pulse?.Invoke(pulseCount);

                if (noOfPulses == pulseCount)
                {
                    LastPulse?.Invoke();
                }
            }
        }