Bloom.CollectionTab.LibraryListView.DownLoadedBooksChanged C# (CSharp) Method

DownLoadedBooksChanged() private method

Called when a file system watcher notices a new book (or some similar change) in our downloaded books folder. This will happen on a thread-pool thread. Since we are updating the UI in response we want to deal with it on the main thread. This also has the effect that it can't happen in the middle of another LoadSourceCollectionButtons().
private DownLoadedBooksChanged ( object sender, ProjectChangedEventArgs eventArgs ) : void
sender object
eventArgs ProjectChangedEventArgs
return void
        private void DownLoadedBooksChanged(object sender, ProjectChangedEventArgs eventArgs)
        {
            SafeInvoke.InvokeIfPossible("LibraryListView update downloaded books",this,true,(Action) (() =>
            {
                // We may notice a change to the downloaded books directory before the other Bloom instance has finished
                // copying the new book there. Finishing should not take long, because the download is done...at worst
                // we have to copy the book on our own filesystem. Typically we only have to move the directory.
                // As a safeguard, wait half a second before we update things.
                if (_newDownloadTimer != null)
                {
                    // Things changed again before we started the update! Forget the old update and wait until things
                    // are stable for the required interval.
                    _newDownloadTimer.Stop();
                    _newDownloadTimer.Dispose();
                }
                _newDownloadTimer = new Timer();
                _newDownloadTimer.Tick += (o, args) =>
                {
                    _newDownloadTimer.Stop();
                    _newDownloadTimer.Dispose();
                    _newDownloadTimer = null;

                    UpdateDownloadedBooks(eventArgs.Path);
                };
                _newDownloadTimer.Interval = 500;
                _newDownloadTimer.Start();
            }));
        }