private bool IsDuplicateEvent(DeviceVolChangedEventArgs newEvent)
 {
     if (newEvent.Equals(lastEventRaised))
     {
         if (lastEventRaisedDateTime.AddSeconds(1) >= DateTime.Now)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
 protected virtual void RaiseDeviceVolChangedEvent(DeviceVolChangedEventArgs e)
 {
     if (IsDuplicateEvent(e))
     {
         Console.WriteLine("Duplicate event, surpressing");
     }
     else
     {
         // Make a temporary copy of the event to avoid possibility of
         // a race condition if the last subscriber unsubscribes
         // immediately after the null check and before the event is raised.
         EventHandler <DeviceVolChangedEventArgs> raiseEvent = DeviceVolChangedEvent;
         lastEventRaised         = e;
         lastEventRaisedDateTime = DateTime.Now;
         // Event will be null if there are no subscribers
         if (raiseEvent != null)
         {
             raiseEvent(this, e);
         }
     }
 }
 public override bool Equals(object obj)
 {
     //Check for null and compare run-time types.
     if ((obj == null) || !this.GetType().Equals(obj.GetType()))
     {
         return(false);
     }
     else
     {
         DeviceVolChangedEventArgs newObj = (DeviceVolChangedEventArgs)obj;
         if (newObj.Name.Equals(Name) &&
             newObj.Volume.Equals(Volume) &&
             newObj.Muted.Equals(Muted) &&
             newObj.EncoderNumbers.SequenceEqual(EncoderNumbers))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }