Hello,
I'm trying to create a progress dialog that shows a progress value from 0 to 100 %.
Doing some research I found out that ProgressDialog() with CancelableProgressorSource() is able to serve this. My current setting is as follows:
public async void ComponentChangedHandler(Component selectedComponent)
{
    using (var progress = new ProgressDialog("Start Work"))
    {
        var status = new CancelableProgressorSource(progress);
        status.Progressor.Max = 100;
        progress.Show();
        await QueuedTask.Run(() =>
        {
            uint step = 0;
            foreach (var dateRange in dateRanges)
            {
                DoSomeLongWork();
                step += 10;
                status.Progressor.Value = step;
            }
        }, status.Progressor);
        progress.Hide();
    }
}This way I'm getting a nice progress dialog with my dialog message and a bar animation spinning from left to right and back again. What I want is a progress bar filling up from left to right increasing percent progress by 10 in each iteration step.
What am I missing here?
Solved! Go to Solution.
When you create the ProgressDialog you have to specify the max steps in the constructor. Like this:
protected override async void OnClick()
{
    using (var progress = new ProgressDialog("Showing Progress", "Canceled", 100, false))
    {
        var status = new CancelableProgressorSource(progress);
        status.Max = 100;
        progress.Show();
        await QueuedTask.Run(async () =>
        {
            uint step = 0;
            for (var idx = 0; idx < 10; idx++)
            {
                await Task.Delay(1000);
                status.Progressor.Value += 10;
                status.Progressor.Status = (status.Progressor.Value * 100 / status.Progressor.Max) + @" % Completed";
                status.Progressor.Message = "Message " + status.Progressor.Value;
            }
        }, status.Progressor);
        progress.Hide();
    }
}There is also a sample available showing an implementation: https://github.com/esri/arcgis-pro-sdk-community-samples/tree/master/Framework/ProgressDialog
When you create the ProgressDialog you have to specify the max steps in the constructor. Like this:
protected override async void OnClick()
{
    using (var progress = new ProgressDialog("Showing Progress", "Canceled", 100, false))
    {
        var status = new CancelableProgressorSource(progress);
        status.Max = 100;
        progress.Show();
        await QueuedTask.Run(async () =>
        {
            uint step = 0;
            for (var idx = 0; idx < 10; idx++)
            {
                await Task.Delay(1000);
                status.Progressor.Value += 10;
                status.Progressor.Status = (status.Progressor.Value * 100 / status.Progressor.Max) + @" % Completed";
                status.Progressor.Message = "Message " + status.Progressor.Value;
            }
        }, status.Progressor);
        progress.Hide();
    }
}There is also a sample available showing an implementation: https://github.com/esri/arcgis-pro-sdk-community-samples/tree/master/Framework/ProgressDialog
I realize that this posting is rather old. However, I am running into a problem attempting to create a progress dialog. I have implemented the code suggested by Wolf and I get absolutely nothing. The task delay of 10 seconds works, but I do not see a progress dialog at all. I have tested this in two different add-ins, including one that was created just to test this functionality. I have also had a fellow team member test on another computer to no effect. In addition I have also checked out and tested with the code from the github link that was included by Wolf. Any thoughts? Am I missing something?
As an fyi, I am developing with ArcGIS Pro 2.9 (if that means anything).
You cannot see the progress dialog if you run from the debugger.
Is there a way to see it also while deugging?