/src/Manos.IO/Manos.IO.Managed/IdleWatcher.cs

http://github.com/jacksonh/manos · C# · 31 lines · 25 code · 6 blank · 0 comment · 3 complexity · 66c5c0ccc1df1b979714e99160acb416 MD5 · raw file

  1. using System;
  2. namespace Manos.IO.Managed
  3. {
  4. class IdleWatcher : Watcher, IIdleWatcher
  5. {
  6. private Action cb;
  7. public IdleWatcher (Context context, Action callback)
  8. : base (context)
  9. {
  10. if (callback == null)
  11. throw new ArgumentNullException ("callback");
  12. this.cb = callback;
  13. }
  14. public void Invoke ()
  15. {
  16. if (IsRunning) {
  17. cb ();
  18. }
  19. }
  20. protected override void Dispose (bool disposing)
  21. {
  22. Context.Remove (this);
  23. }
  24. }
  25. }