Example #1
0
        protected virtual async Task AddPlaylistItems(IEnumerable <string> paths, CancellationToken cancellationToken)
        {
            using (var transaction = this.Database.BeginTransaction(this.Database.PreferredIsolationLevel))
            {
                using (var playlistPopulator = new PlaylistPopulator(this.Database, this.PlaybackManager, this.Sequence, this.Offset, this.Visible, transaction))
                {
                    playlistPopulator.InitializeComponent(this.Core);
                    await this.WithSubTask(playlistPopulator,
                                           () => playlistPopulator.Populate(this.Playlist, paths, cancellationToken)
                                           ).ConfigureAwait(false);

                    this.Offset = playlistPopulator.Offset;
                }
                transaction.Commit();
            }
        }
Example #2
0
        protected virtual async Task AddPlaylistItems(IEnumerable <string> paths, CancellationToken cancellationToken)
        {
            //We don't know how many files we're about to enumerate.
            if (!this.IsIndeterminate)
            {
                await this.SetIsIndeterminate(true).ConfigureAwait(false);
            }
            using (var transaction = this.Database.BeginTransaction(this.Database.PreferredIsolationLevel))
            {
                using (var playlistPopulator = new PlaylistPopulator(this.Database, this.PlaybackManager, this.Sequence, this.Offset, this.Visible, transaction))
                {
                    playlistPopulator.InitializeComponent(this.Core);
                    await this.WithSubTask(playlistPopulator,
                                           async() => await playlistPopulator.Populate(paths, cancellationToken)
                                           .ConfigureAwait(false)).ConfigureAwait(false);

                    this.Offset = playlistPopulator.Offset;
                }
                transaction.Commit();
            }
        }