EPG: EIT alle 60s auf Background-Thread - kein UI-Block

This commit is contained in:
administrator 2026-05-13 11:36:39 +02:00
parent 6249c6d149
commit 6e10f0b979

View file

@ -66,12 +66,28 @@ public partial class MainWindow : Window
_epgTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) };
_epgTimer.Tick += EpgTimer_Tick;
// Jede 60s: XMLTV Jetzt/Danach refreshen
// Jede 60s: XMLTV Jetzt/Danach refreshen + EIT neu lesen
_epgRefreshTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(60) };
_epgRefreshTimer.Tick += (_, _) =>
{
if (_currentChannel != null)
UpdateNextFromEpgService(_currentChannel);
if (_currentChannel == null) return;
// EIT auf Background-Thread lesen damit UI nicht blockiert
if (_currentChannel.Source == ChannelSource.FritzBox && _currentMedia != null)
{
var media = _currentMedia;
Task.Run(() =>
{
try
{
var nowPlaying = media.Meta(MetadataType.NowPlaying) ?? "";
var showName = media.Meta(MetadataType.ShowName) ?? "";
if (!string.IsNullOrWhiteSpace(nowPlaying) || !string.IsNullOrWhiteSpace(showName))
Dispatcher.BeginInvoke(() => UpdateEpgFromMedia(media));
}
catch { }
});
}
UpdateNextFromEpgService(_currentChannel);
};
_epgRefreshTimer.Start();