Esempio n. 1
0
        private void TimerCallback(object state)
        {
            lock (_libraryChangedSyncLock)
            {
                try
                {
                    var itemsUpdated = _itemsUpdated
#if EMBY
                                       .GroupBy(i => i.ItemId)
#else
                                       .GroupBy(i => i.Guid)
#endif
                                       .Select(grp => grp.First())
                                       .Select(i => { i.LastModified = DateTime.UtcNow.ToFileTime(); return(i); })
                                       .ToList();
                    var itemsRemoved = _itemsRemoved
#if EMBY
                                       .GroupBy(i => i.ItemId)
#else
                                       .GroupBy(i => i.Guid)
#endif
                                       .Select(grp => grp.First())
                                       .Select(i => { i.LastModified = DateTime.UtcNow.ToFileTime(); return(i); })
                                       .ToList();

                    Plugin.Instance.Db.SaveItems(itemsUpdated);
                    Plugin.Instance.Db.SaveItems(itemsRemoved);

                    if (WriteTimer != null)
                    {
                        WriteTimer.Dispose();
                        WriteTimer = null;
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError(e, $"An error in TimerCallback: {e}");
                }

                _itemsRemoved.Clear();
                _itemsUpdated.Clear();
            }
        }
Esempio n. 2
0
        private void TimerCallback(object state)
        {
            lock (_syncLock)
                try
                {
                    var changes = _changedItems.ToList();
                    _changedItems.Clear();

                    SendNotifications(changes);

                    if (UpdateTimer != null)
                    {
                        UpdateTimer.Dispose();
                        UpdateTimer = null;
                    }
                }
                catch (Exception e)
                {
                    _logger.LogError(e, $"An Error Has Occurred in TimerCallback: {e}");
                }
        }