Beispiel #1
0
        /// <summary>
        /// Register messages
        /// </summary>
        private void RegisterMessages()
        {
            Messenger.Default.Register <ChangeLanguageMessage>(
                this,
                async message =>
            {
                foreach (var movie in Movies.ToList())
                {
                    try
                    {
                        await Task.Delay(1000, CancellationLoadingMovies.Token);
                    }
                    catch (TaskCanceledException)
                    {
                        Logger.Info(
                            $"Stopped translating movie : {movie.Title}");
                        return;
                    }

                    await MovieService.TranslateMovieShortAsync(movie, CancellationLoadingMovies.Token);
                }
            });

            Messenger.Default.Register <ChangeFavoriteMovieMessage>(
                this,
                async message => await MovieHistoryService.SetMovieHistoryAsync(Movies));
        }
Beispiel #2
0
        /// <summary>
        /// Register messages
        /// </summary>
        private void RegisterMessages()
        {
            Messenger.Default.Register <ChangeLanguageMessage>(
                this,
                message =>
            {
                Parallel.ForEach(Movies, async movie =>
                {
                    await MovieService.TranslateMovieAsync(movie);
                });
            });

            Messenger.Default.Register <ChangeFavoriteMovieMessage>(
                this,
                async message => await MovieHistoryService.SetMovieHistoryAsync(Movies));
        }