ResourceEntryPoint.cs 932 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using MediaBrowser.Controller.Plugins;
  2. using System;
  3. using System.Threading;
  4. namespace MediaBrowser.ServerApplication.EntryPoints
  5. {
  6. public class ResourceEntryPoint : IServerEntryPoint
  7. {
  8. private Timer _timer;
  9. public void Run()
  10. {
  11. _timer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(30));
  12. }
  13. private void TimerCallback(object state)
  14. {
  15. try
  16. {
  17. // Bad practice, i know. But we keep a lot in memory, unfortunately.
  18. GC.Collect(2, GCCollectionMode.Forced, true);
  19. GC.Collect(2, GCCollectionMode.Forced, true);
  20. }
  21. catch
  22. {
  23. }
  24. }
  25. public void Dispose()
  26. {
  27. if (_timer != null)
  28. {
  29. _timer.Dispose();
  30. _timer = null;
  31. }
  32. }
  33. }
  34. }