示例#1
0
 private void Event()
 {
     Control.SecondChange += (ss, ee) =>
     {
         SecondChange?.Invoke(this, new TimeUpdateEventArgs());
     };
     Control.DayChange += (ss, ee) =>
     {
         DayChange?.Invoke(this, new TimeUpdateEventArgs());
     };
     Control.HourChange += (ss, ee) =>
     {
         HourChange?.Invoke(this, new TimeUpdateEventArgs());
     };
     Control.MinuteChange += (ss, ee) =>
     {
         MinuteChange?.Invoke(this, new TimeUpdateEventArgs());
     };
     Control.MonthChange += (ss, ee) =>
     {
         MonthChange?.Invoke(this, new TimeUpdateEventArgs());
     };
     Control.YearChange += (ss, ee) =>
     {
         YearChange?.Invoke(this, new TimeUpdateEventArgs());
     };
     Control.MillisecondChange += (ss, ee) =>
     {
         MillisecondChange?.Invoke(ss, ee);
     };
 }
        public void GetUpdatedTimeOnSecondChange()
        {
            for (; ;)
            {
                Thread.Sleep(2000);

                DateTime dbDateTime = DateTime.Now; // get data from Database

                if (dbDateTime.Second != _second)
                {
                    // we can use any one option...
                    // option 1
                    Notify(dbDateTime.ToLongTimeString());
                    //option 2
                    SecondChange?.Invoke(dbDateTime.ToLongTimeString());
                }

                _second = dbDateTime.Second;
            }
        }
示例#3
0
        private void Event()
        {
            try
            {
                foreach (var list in timeChange)
                {
                    switch (list)
                    {
                    case TimeChange.Second:
                        SecondChange?.Invoke(this, new TimeUpdateEventArgs());
                        break;

                    case TimeChange.Minute:
                        MinuteChange?.Invoke(this, new TimeUpdateEventArgs());
                        break;

                    case TimeChange.Hour:
                        HourChange?.Invoke(this, new TimeUpdateEventArgs());
                        break;

                    case TimeChange.Day:
                        DayChange?.Invoke(this, new TimeUpdateEventArgs());
                        break;

                    case TimeChange.Month:
                        MonthChange?.Invoke(this, new TimeUpdateEventArgs());
                        break;

                    case TimeChange.Year:
                        YearChange?.Invoke(this, new TimeUpdateEventArgs());
                        break;

                    default: break;
                    }
                }
            }
            catch
            {
            }
        }
 private void Notify(string str)
 {
     SecondChange?.Invoke(str);
 }
示例#5
0
 // The method which fires the Event
 protected void OnSecondChange(object clock, TimeInfoEventArgs timeInformation)
 {
     // Check if there are any Subscribers
     // Call the Event
     SecondChange?.Invoke(clock, timeInformation);
 }
示例#6
0
 //Method which fires the event
 protected void OnSecondChange(object clock, TimeInfoEventArgs timeInfo)
 {
     SecondChange?.Invoke(clock, timeInfo);
 }