diff --git a/AaxDecrypter/AaxDecrypter.csproj b/AaxDecrypter/AaxDecrypter.csproj index 17e91d82..da628c8d 100644 --- a/AaxDecrypter/AaxDecrypter.csproj +++ b/AaxDecrypter/AaxDecrypter.csproj @@ -6,7 +6,7 @@ - + diff --git a/FileManager/FileManager.csproj b/FileManager/FileManager.csproj index 304d8134..718e4303 100644 --- a/FileManager/FileManager.csproj +++ b/FileManager/FileManager.csproj @@ -5,7 +5,7 @@ - + diff --git a/InternalUtilities/InternalUtilities.csproj b/InternalUtilities/InternalUtilities.csproj index c96bf718..cd724b55 100644 --- a/InternalUtilities/InternalUtilities.csproj +++ b/InternalUtilities/InternalUtilities.csproj @@ -5,7 +5,7 @@ - + diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index 5c081601..615324c6 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 5.6.5.1 + 5.6.5.5 diff --git a/LibationWinForms/AsyncNotifyPropertyChanged.cs b/LibationWinForms/AsyncNotifyPropertyChanged.cs index 136930aa..9cc1bd39 100644 --- a/LibationWinForms/AsyncNotifyPropertyChanged.cs +++ b/LibationWinForms/AsyncNotifyPropertyChanged.cs @@ -9,6 +9,6 @@ namespace LibationWinForms public event PropertyChangedEventHandler PropertyChanged; public void NotifyPropertyChanged([CallerMemberName] string propertyName = "") - => this.UIThread(() => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName))); + => this.UIThreadAsync(() => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName))); } } diff --git a/LibationWinForms/BookLiberation/AudioDecodeForm.cs b/LibationWinForms/BookLiberation/AudioDecodeForm.cs index aa3cfa3e..255268c4 100644 --- a/LibationWinForms/BookLiberation/AudioDecodeForm.cs +++ b/LibationWinForms/BookLiberation/AudioDecodeForm.cs @@ -1,8 +1,8 @@ -using DataLayer; +using System; +using DataLayer; using Dinah.Core.Net.Http; -using Dinah.Core.Windows.Forms; +using Dinah.Core.Threading; using LibationWinForms.BookLiberation.BaseForms; -using System; namespace LibationWinForms.BookLiberation { @@ -47,7 +47,7 @@ namespace LibationWinForms.BookLiberation if (downloadProgress.ProgressPercentage == 0) updateRemainingTime(0); else - progressBar1.UIThread(() => progressBar1.Value = (int)downloadProgress.ProgressPercentage); + progressBar1.UIThreadAsync(() => progressBar1.Value = (int)downloadProgress.ProgressPercentage); } public override void OnStreamingTimeRemaining(object sender, TimeSpan timeRemaining) @@ -61,7 +61,7 @@ namespace LibationWinForms.BookLiberation public override void OnTitleDiscovered(object sender, string title) { - this.UIThread(() => this.Text = DecodeActionName + " " + title); + this.UIThreadAsync(() => this.Text = DecodeActionName + " " + title); this.title = title; updateBookInfo(); } @@ -79,14 +79,14 @@ namespace LibationWinForms.BookLiberation } public override void OnCoverImageDiscovered(object sender, byte[] coverArt) - => pictureBox1.UIThread(() => pictureBox1.Image = Dinah.Core.Drawing.ImageReader.ToImage(coverArt)); + => pictureBox1.UIThreadAsync(() => pictureBox1.Image = Dinah.Core.Drawing.ImageReader.ToImage(coverArt)); #endregion // thread-safe UI updates private void updateBookInfo() - => bookInfoLbl.UIThread(() => bookInfoLbl.Text = $"{title}\r\nBy {authorNames}\r\nNarrated by {narratorNames}"); + => bookInfoLbl.UIThreadAsync(() => bookInfoLbl.Text = $"{title}\r\nBy {authorNames}\r\nNarrated by {narratorNames}"); private void updateRemainingTime(int remaining) - => remainingTimeLbl.UIThread(() => remainingTimeLbl.Text = $"ETA:\r\n{remaining} sec"); + => remainingTimeLbl.UIThreadAsync(() => remainingTimeLbl.Text = $"ETA:\r\n{remaining} sec"); } } diff --git a/LibationWinForms/BookLiberation/AutomatedBackupsForm.cs b/LibationWinForms/BookLiberation/AutomatedBackupsForm.cs index 14a114e7..2a800e3d 100644 --- a/LibationWinForms/BookLiberation/AutomatedBackupsForm.cs +++ b/LibationWinForms/BookLiberation/AutomatedBackupsForm.cs @@ -1,7 +1,6 @@ -using Dinah.Core.Windows.Forms; -using System; -using System.Linq; +using System; using System.Windows.Forms; +using Dinah.Core.Threading; namespace LibationWinForms.BookLiberation { @@ -19,7 +18,7 @@ namespace LibationWinForms.BookLiberation public void WriteLine(string text) { if (!IsDisposed) - logTb.UIThread(() => logTb.AppendText($"{DateTime.Now} {text}{Environment.NewLine}")); + logTb.UIThreadAsync(() => logTb.AppendText($"{DateTime.Now} {text}{Environment.NewLine}")); } public void FinalizeUI() diff --git a/LibationWinForms/BookLiberation/BaseForms/LiberationBaseForm.cs b/LibationWinForms/BookLiberation/BaseForms/LiberationBaseForm.cs index 8df2b4d5..5cd32e01 100644 --- a/LibationWinForms/BookLiberation/BaseForms/LiberationBaseForm.cs +++ b/LibationWinForms/BookLiberation/BaseForms/LiberationBaseForm.cs @@ -1,9 +1,9 @@ -using DataLayer; +using System; +using System.Windows.Forms; +using DataLayer; using Dinah.Core.Net.Http; using Dinah.Core.Threading; using FileLiberator; -using System; -using System.Windows.Forms; namespace LibationWinForms.BookLiberation.BaseForms { @@ -122,8 +122,8 @@ namespace LibationWinForms.BookLiberation.BaseForms /// /// If the form was shown using Show (not ShowDialog), Form.Close calls Form.Dispose /// - private void OnStreamingCompletedClose(object sender, string completedString) => this.UIThread(Close); - private void OnCompletedDispose(object sender, LibraryBook e) => this.UIThread(Dispose); + private void OnStreamingCompletedClose(object sender, string completedString) => this.UIThreadAsync(Close); + private void OnCompletedDispose(object sender, LibraryBook e) => this.UIThreadAsync(Dispose); /// /// If StreamingBegin is fired from a worker thread, the window will be created on that @@ -132,7 +132,7 @@ namespace LibationWinForms.BookLiberation.BaseForms /// could cause it to freeze. Form.BeginInvoke won't work until the form is created /// (ie. shown) because Control doesn't get a window handle until it is Shown. /// - private void OnStreamingBeginShow(object sender, string beginString) => Invoker.UIThread(Show); + private void OnStreamingBeginShow(object sender, string beginString) => Invoker.UIThreadAsync(Show); #endregion diff --git a/LibationWinForms/BookLiberation/DownloadForm.cs b/LibationWinForms/BookLiberation/DownloadForm.cs index e503deac..1843aaa3 100644 --- a/LibationWinForms/BookLiberation/DownloadForm.cs +++ b/LibationWinForms/BookLiberation/DownloadForm.cs @@ -1,9 +1,8 @@ -using Dinah.Core.Net.Http; -using Dinah.Core.Windows.Forms; -using LibationWinForms.BookLiberation.BaseForms; -using System; -using System.Linq; +using System; using System.Windows.Forms; +using Dinah.Core.Net.Http; +using Dinah.Core.Threading; +using LibationWinForms.BookLiberation.BaseForms; namespace LibationWinForms.BookLiberation { @@ -21,7 +20,7 @@ namespace LibationWinForms.BookLiberation #region IStreamable event handler overrides public override void OnStreamingBegin(object sender, string beginString) { - filenameLbl.UIThread(() => filenameLbl.Text = beginString); + filenameLbl.UIThreadAsync(() => filenameLbl.Text = beginString); } public override void OnStreamingProgressChanged(object sender, DownloadProgress downloadProgress) { @@ -29,11 +28,11 @@ namespace LibationWinForms.BookLiberation if (!downloadProgress.TotalBytesToReceive.HasValue || downloadProgress.TotalBytesToReceive.Value <= 0) return; - progressLbl.UIThread(() => progressLbl.Text = $"{downloadProgress.BytesReceived:#,##0} of {downloadProgress.TotalBytesToReceive.Value:#,##0}"); + progressLbl.UIThreadAsync(() => progressLbl.Text = $"{downloadProgress.BytesReceived:#,##0} of {downloadProgress.TotalBytesToReceive.Value:#,##0}"); var d = double.Parse(downloadProgress.BytesReceived.ToString()) / double.Parse(downloadProgress.TotalBytesToReceive.Value.ToString()) * 100.0; var i = int.Parse(Math.Truncate(d).ToString()); - progressBar1.UIThread(() => progressBar1.Value = i); + progressBar1.UIThreadAsync(() => progressBar1.Value = i); lastDownloadProgress = DateTime.Now; } @@ -50,14 +49,14 @@ namespace LibationWinForms.BookLiberation private void timer_Tick(object sender, EventArgs e) { // if no update in the last 30 seconds, display frozen label - lastUpdateLbl.UIThread(() => lastUpdateLbl.Visible = lastDownloadProgress.AddSeconds(30) < DateTime.Now); + lastUpdateLbl.UIThreadAsync(() => lastUpdateLbl.Visible = lastDownloadProgress.AddSeconds(30) < DateTime.Now); if (lastUpdateLbl.Visible) { var diff = DateTime.Now - lastDownloadProgress; var min = (int)diff.TotalMinutes; var minText = min > 0 ? $"{min}min " : ""; - lastUpdateLbl.UIThread(() => lastUpdateLbl.Text = $"Frozen? Last download activity: {minText}{diff.Seconds}sec ago"); + lastUpdateLbl.UIThreadAsync(() => lastUpdateLbl.Text = $"Frozen? Last download activity: {minText}{diff.Seconds}sec ago"); } } private void DownloadForm_FormClosing(object sender, FormClosingEventArgs e) => timer.Stop(); diff --git a/LibationWinForms/Form1.cs b/LibationWinForms/Form1.cs index d1891266..3b1fe2a0 100644 --- a/LibationWinForms/Form1.cs +++ b/LibationWinForms/Form1.cs @@ -3,10 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using ApplicationServices; -using DataLayer; using Dinah.Core; using Dinah.Core.Drawing; -using Dinah.Core.Windows.Forms; +using Dinah.Core.Threading; using FileManager; using InternalUtilities; using LibationWinForms.Dialogs; @@ -134,11 +133,11 @@ namespace LibationWinForms // suppressed filter while init'ing UI var prev_isProcessingGridSelect = isProcessingGridSelect; isProcessingGridSelect = true; - this.UIThread(() => setGrid()); + this.UIThreadSync(() => setGrid()); isProcessingGridSelect = prev_isProcessingGridSelect; // UI init complete. now we can apply filter - this.UIThread(() => doFilter(lastGoodFilter)); + this.UIThreadAsync(() => doFilter(lastGoodFilter)); setBackupCounts(null, null); } @@ -158,7 +157,7 @@ namespace LibationWinForms currProductsGrid = new ProductsGrid { Dock = DockStyle.Fill }; currProductsGrid.VisibleCountChanged += setVisibleCount; - gridPanel.UIThread(() => gridPanel.Controls.Add(currProductsGrid)); + gridPanel.UIThreadSync(() => gridPanel.Controls.Add(currProductsGrid)); currProductsGrid.Display(); } ResumeLayout(); @@ -229,9 +228,9 @@ namespace LibationWinForms : "All books have been liberated"; // update UI - statusStrip1.UIThread(() => backupsCountsLbl.Text = statusStripText); - menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Enabled = pending > 0); - menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Text = string.Format(beginBookBackupsToolStripMenuItem_format, menuItemText)); + statusStrip1.UIThreadAsync(() => backupsCountsLbl.Text = statusStripText); + menuStrip1.UIThreadAsync(() => beginBookBackupsToolStripMenuItem.Enabled = pending > 0); + menuStrip1.UIThreadAsync(() => beginBookBackupsToolStripMenuItem.Text = string.Format(beginBookBackupsToolStripMenuItem_format, menuItemText)); } private void setPdfBackupCounts(LibraryCommands.LibraryStats libraryStats) { @@ -251,9 +250,9 @@ namespace LibationWinForms : "All PDFs have been downloaded"; // update UI - statusStrip1.UIThread(() => pdfsCountsLbl.Text = statusStripText); - menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Enabled = libraryStats.pdfsNotDownloaded > 0); - menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Text = string.Format(beginPdfBackupsToolStripMenuItem_format, menuItemText)); + statusStrip1.UIThreadAsync(() => pdfsCountsLbl.Text = statusStripText); + menuStrip1.UIThreadAsync(() => beginPdfBackupsToolStripMenuItem.Enabled = libraryStats.pdfsNotDownloaded > 0); + menuStrip1.UIThreadAsync(() => beginPdfBackupsToolStripMenuItem.Text = string.Format(beginPdfBackupsToolStripMenuItem_format, menuItemText)); } #endregion diff --git a/LibationWinForms/LibationWinForms.csproj b/LibationWinForms/LibationWinForms.csproj index 4f6d0f3c..dacc738d 100644 --- a/LibationWinForms/LibationWinForms.csproj +++ b/LibationWinForms/LibationWinForms.csproj @@ -13,7 +13,7 @@ - +