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();
}));
}