Replies: 5 comments 4 replies
-
Hey @nlogozzo, the code in the i.e. You could block on the private void DoWork(object sender, DoWorkEventArgs e) => _toExecute()
.ConfigureAwait(false)
.GetAwaiter()
.GetResult(); Note that you shouldn't need to call You also shouldn't need the |
Beta Was this translation helpful? Give feedback.
-
Yeah I want the progress dialog to be intermittent as it just executes an asynchronous task and calls it a day ... no need to report progress, just show something is happening and when it’s done, it’s done
--Project I'm using this with: https://github.com/nlogozzo/Nickvision.WPF
… On Apr 17, 2021, at 5:14 PM, C. Augusto Proiete ***@***.***> wrote:
@nlogozzo MarqueeProgressBar is a style that is intermittent, and doesn't really show incremental progress.
You're supposed to call progressDialog.ReportProgress with a number between 0 and 100 as you execute your task, to make the progress bar move.
e.g.
progressDialog.ReportProgress(x, null, $"Processing: {x}%");
There is an example of usage of all dialogs in the Sample project. For the ProgressDialog look for _sampleProgressDialog
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Beta Was this translation helpful? Give feedback.
-
Hey @augustoproiete. For some reason it's not working correctly. Here is my service implementation /// <summary>
/// Shows a progress dialog
/// </summary>
/// <param name="description">The description of the task</param>
/// <param name="task">The async task</param>
/// <param name="configureAwait">The bool to pass to the Task's ConfigureAwait method</param>
public void ShowDialog(string description, Func<Task> task, bool configureAwait = true)
{
using var progressDialog = new ProgressDialog()
{
WindowTitle = "Progress Dialog",
Text = description,
Description = "Please Wait...",
ShowCancelButton = false,
ProgressBarStyle = ProgressBarStyle.MarqueeProgressBar
};
progressDialog.DoWork += (sender, e) => task().ConfigureAwait(configureAwait).GetAwaiter().GetResult();
progressDialog.ShowDialog();
} Now when I try to run this update function through the progress dialog var updater = new Updater("https://raw.githubusercontent.com/nlogozzo/NickvisionApp/main/NickvisionApp/UpdateConfig.json", Assembly.GetExecutingAssembly().GetName().Version);
_progressDialogService.ShowDialog("Checking for update...", async () => await updater.CheckForUpdateAsync());
if (updater.UpdateAvailable)
{
...
}
else
{
await _contentDialogService.ShowAsync("No update is available at this time", "No Update Available", "OK");
} I also tried just passing |
Beta Was this translation helpful? Give feedback.
-
I've come to the conclusion that the Win32 ProgressDialog implementation doesn't have good enough support for async command. |
Beta Was this translation helpful? Give feedback.
-
IMO, It is preferable to migrate away from From official documentation: The async-based approach to asynchronous programming is preferable to existing approaches in almost every case. In particular, this approach is better than the BackgroundWorker class for I/O-bound operations because the code is simpler and you don't have to guard against race conditions. In combination with the Task.Run method, async programming is better than BackgroundWorker for CPU-bound operations because async programming separates the coordination details of running your code from the work that Task.Run transfers to the thread pool. |
Beta Was this translation helpful? Give feedback.
-
Hi I have a ProgressDialogService meant to take an async function and run it in the ProgressDialog as some async functions take some time.
However, when I try to show the dialog I get no error and no dialog shows up:
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions