/src/Manos.IO/Manos.IO.Managed/CheckWatcher.cs

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

  1. using System;
  2. namespace Manos.IO.Managed
  3. {
  4. class CheckWatcher : Watcher, ICheckWatcher
  5. {
  6. private Action cb;
  7. public CheckWatcher (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. }