Permalink
Browse files

TVrecordings: Launch "DeleteInvalidRecordings" async for faster GUI l…

…oading
  • Loading branch information...
1 parent 663c656 commit c86b6c4f7c97d1cab044c1ddefc6f11a05d86913 @GuzziMP GuzziMP committed Dec 27, 2012
Showing with 17 additions and 1 deletion.
  1. +17 −1 TvEngine3/TVLibrary/TvPlugin/TvPlugin/TvRecorded.cs
@@ -25,6 +25,7 @@
using System.Threading;
using System.Windows.Forms;
using System.Linq;
+using System.Diagnostics;
using Gentle.Common;
using MediaPortal.Dialogs;
using MediaPortal.GUI.Library;
@@ -364,7 +365,19 @@ protected override void OnPageLoad()
base.OnPageLoad();
InitViewSelections();
- DeleteInvalidRecordings();
+
+ // launch DeleteInvalidRecordings async for instant start of GUI screen
+ new Thread(delegate()
+ {
+ try
+ {
+ DeleteInvalidRecordings();
+ }
+ catch (Exception ex)
+ {
+ Log.Debug("DeleteInvalidRecordings - error: " + ex.Message);
+ }
+ }) { Name = "DeleteInvalidRecordings", IsBackground = true, Priority = ThreadPriority.BelowNormal }.Start();
if (btnCompress != null)
{
@@ -1376,7 +1389,10 @@ private void DeleteWatchedRecordings(string currentTitle)
private void DeleteInvalidRecordings()
{
+ Stopwatch watch = new Stopwatch(); watch.Reset(); watch.Start();
RemoteControl.Instance.DeleteInvalidRecordings();
+ watch.Stop();
+ Log.Debug("DeleteInvalidRecordings() - finished after '" + watch.ElapsedMilliseconds + "' ms.");
}
private void UpdateProperties()

2 comments on commit c86b6c4

Owner

arion-p replied Jan 1, 2013

The reason DeleteInvalidRecordings was called synchronously was to ensure it finishes before the list of recordings is returned to the client so that it does not include invalid ones. How is this accomplished in the async case?

Member

tourettes replied Jan 6, 2013

MP UI should be refreshed when the async callback returns.

Btw. why the MP client even has to make such checks? Isn't it TVE's responsible to keep the content as valid? In my opinion the TVE should check the regording state in background if there is a need for such. It should listen the filesystem events when it is running and on startup it should be doing the same check what DeleteInvalidRecordings() us currently doing.

Please sign in to comment.