<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Progress bar status trouble in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/progress-bar-status-trouble/m-p/1287213#M9792</link>
    <description>&lt;P&gt;Assuming that you are using the&amp;nbsp;CancelableProgressorSource:&lt;/P&gt;&lt;P&gt;You can try setting the following properties for the CancelableProgressorSource instance to change the Progress bar UI:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//     Gets or sets the message of the progress dialog displayed while the associated
//     Task is executing.
public string Message { get; set; }

//     Gets or sets the status of the progress dialog displayed while the associated
//     Task is executing.
public string Status { get; set; }

//     Gets or sets the extended status of the progress dialog displayed while the associated
//     Task is executing.
public string ExtendedStatus  { get; set; }

//     Gets or sets the progress bar position within the progress dialog displayed while
//     the associated Task is executing.
public uint Value  { get; set; }

//     Gets or sets the progress bar maximum value within the dialog displayed while
//     the associated Task is executing.
public uint Max { get; set; }&lt;/LI-CODE&gt;&lt;P&gt;Unfortunately, this class is not listed in our API Reference, I am trying to get this fixed with the next release.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a sample tool that i using the progress bar and changes its properties:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;/// &amp;lt;summary&amp;gt;
/// This tool can be used to digitize a polygon on a map and once complete
/// the tool performs a series of buffer operations with expanding buffers
/// During the buffer creation process the Progress Dialog is displayed
/// &amp;lt;/remarks&amp;gt;
internal class MultiBufferTool : MapTool
{
  /// &amp;lt;summary&amp;gt;
  /// Constructor of BufferGeometry tool
  /// &amp;lt;/summary&amp;gt;
  public MultiBufferTool()
  {
    IsSketchTool = true;
    SketchType = SketchGeometryType.Polygon;
    SketchOutputMode = SketchOutputMode.Map;
  }

  /// &amp;lt;summary&amp;gt;
  /// Constructs the value array to be passed as parameter to ExecuteToolAsync
  /// Runs the Buffer tool of Analysis toolbox
  /// &amp;lt;/summary&amp;gt;
  /// &amp;lt;param name="geometry"&amp;gt;&amp;lt;/param&amp;gt;
  /// &amp;lt;returns&amp;gt;Geoprocessing result object as a Task&amp;lt;/returns&amp;gt;
  protected override async Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry)
  {
    uint numBuffers = 7;

    // create and initialize the progress dialog
    // Note: Progress dialogs are not displayed when debugging in Visual Studio
    var progDlg = new ProgressDialog($@"Creating {numBuffers} buffers", "Canceled", false);
    var progsrc=new CancelableProgressorSource(progDlg);
    for (uint iBuffer = 1; iBuffer &amp;lt;= numBuffers; iBuffer++)
    {
      var valueArray = await QueuedTask.Run&amp;lt;IReadOnlyList&amp;lt;string&amp;gt;&amp;gt;(() =&amp;gt;
      {
        var geometries = new List&amp;lt;object&amp;gt;() { geometry };
        // Creates a 100-meter buffer around the geometry object
        // null indicates a default output name is used
        var valueArray = Geoprocessing.MakeValueArray(geometries, null, $@"{iBuffer*100} Meters");
        return valueArray;
      });
      progsrc.ExtendedStatus = $@"Creating buffer #: {iBuffer} of {numBuffers}";
      progsrc.Value = 100 * (iBuffer-1);
      progsrc.Max = 100 * numBuffers + 1;
        
      var gpResult = await Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArray, null, progsrc.Progressor);
      if(gpResult.IsFailed)
      {
        // display error messages if the tool fails, otherwise shows the default messages
        if (gpResult.Messages.Count() != 0)
        {
          Geoprocessing.ShowMessageBox(gpResult.Messages, progsrc.Message,
                          gpResult.IsFailed ?
                          GPMessageBoxStyle.Error : GPMessageBoxStyle.Default);
        }
        else
        {
          MessageBox.Show($@"{progsrc.Message} failed with errorcode, check parameters.");
        }
        break;
      }

      // check if the operator cancelled
      if (progsrc.CancellationTokenSource.IsCancellationRequested) break;
    }
    if (progsrc.CancellationTokenSource.IsCancellationRequested)
    {
      MessageBox.Show("The operation was cancelled.");
    }
    return true;
  }
}&lt;/LI-CODE&gt;&lt;P&gt;The above sample code displays the progressbar like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_0-1683636758748.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/70221i2399C2B970115C7F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_0-1683636758748.png" alt="Wolf_0-1683636758748.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 May 2023 13:07:46 GMT</pubDate>
    <dc:creator>Wolf</dc:creator>
    <dc:date>2023-05-09T13:07:46Z</dc:date>
    <item>
      <title>Progress bar status trouble</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/progress-bar-status-trouble/m-p/1287109#M9789</link>
      <description>&lt;P&gt;Hello, I've been using ArcGIS Pro 2.9.4, and using ArcGIS SDK to implement progress bar to show how long it will take until the process ends.&lt;/P&gt;&lt;P&gt;I want nothing under the progress bar, but status "finishing up..." always show up.&lt;/P&gt;&lt;P&gt;How could I get rid of it?&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 01:29:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/progress-bar-status-trouble/m-p/1287109#M9789</guid>
      <dc:creator>DeviceWorksOfficial</dc:creator>
      <dc:date>2023-05-09T01:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Progress bar status trouble</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/progress-bar-status-trouble/m-p/1287213#M9792</link>
      <description>&lt;P&gt;Assuming that you are using the&amp;nbsp;CancelableProgressorSource:&lt;/P&gt;&lt;P&gt;You can try setting the following properties for the CancelableProgressorSource instance to change the Progress bar UI:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//     Gets or sets the message of the progress dialog displayed while the associated
//     Task is executing.
public string Message { get; set; }

//     Gets or sets the status of the progress dialog displayed while the associated
//     Task is executing.
public string Status { get; set; }

//     Gets or sets the extended status of the progress dialog displayed while the associated
//     Task is executing.
public string ExtendedStatus  { get; set; }

//     Gets or sets the progress bar position within the progress dialog displayed while
//     the associated Task is executing.
public uint Value  { get; set; }

//     Gets or sets the progress bar maximum value within the dialog displayed while
//     the associated Task is executing.
public uint Max { get; set; }&lt;/LI-CODE&gt;&lt;P&gt;Unfortunately, this class is not listed in our API Reference, I am trying to get this fixed with the next release.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a sample tool that i using the progress bar and changes its properties:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;/// &amp;lt;summary&amp;gt;
/// This tool can be used to digitize a polygon on a map and once complete
/// the tool performs a series of buffer operations with expanding buffers
/// During the buffer creation process the Progress Dialog is displayed
/// &amp;lt;/remarks&amp;gt;
internal class MultiBufferTool : MapTool
{
  /// &amp;lt;summary&amp;gt;
  /// Constructor of BufferGeometry tool
  /// &amp;lt;/summary&amp;gt;
  public MultiBufferTool()
  {
    IsSketchTool = true;
    SketchType = SketchGeometryType.Polygon;
    SketchOutputMode = SketchOutputMode.Map;
  }

  /// &amp;lt;summary&amp;gt;
  /// Constructs the value array to be passed as parameter to ExecuteToolAsync
  /// Runs the Buffer tool of Analysis toolbox
  /// &amp;lt;/summary&amp;gt;
  /// &amp;lt;param name="geometry"&amp;gt;&amp;lt;/param&amp;gt;
  /// &amp;lt;returns&amp;gt;Geoprocessing result object as a Task&amp;lt;/returns&amp;gt;
  protected override async Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry)
  {
    uint numBuffers = 7;

    // create and initialize the progress dialog
    // Note: Progress dialogs are not displayed when debugging in Visual Studio
    var progDlg = new ProgressDialog($@"Creating {numBuffers} buffers", "Canceled", false);
    var progsrc=new CancelableProgressorSource(progDlg);
    for (uint iBuffer = 1; iBuffer &amp;lt;= numBuffers; iBuffer++)
    {
      var valueArray = await QueuedTask.Run&amp;lt;IReadOnlyList&amp;lt;string&amp;gt;&amp;gt;(() =&amp;gt;
      {
        var geometries = new List&amp;lt;object&amp;gt;() { geometry };
        // Creates a 100-meter buffer around the geometry object
        // null indicates a default output name is used
        var valueArray = Geoprocessing.MakeValueArray(geometries, null, $@"{iBuffer*100} Meters");
        return valueArray;
      });
      progsrc.ExtendedStatus = $@"Creating buffer #: {iBuffer} of {numBuffers}";
      progsrc.Value = 100 * (iBuffer-1);
      progsrc.Max = 100 * numBuffers + 1;
        
      var gpResult = await Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArray, null, progsrc.Progressor);
      if(gpResult.IsFailed)
      {
        // display error messages if the tool fails, otherwise shows the default messages
        if (gpResult.Messages.Count() != 0)
        {
          Geoprocessing.ShowMessageBox(gpResult.Messages, progsrc.Message,
                          gpResult.IsFailed ?
                          GPMessageBoxStyle.Error : GPMessageBoxStyle.Default);
        }
        else
        {
          MessageBox.Show($@"{progsrc.Message} failed with errorcode, check parameters.");
        }
        break;
      }

      // check if the operator cancelled
      if (progsrc.CancellationTokenSource.IsCancellationRequested) break;
    }
    if (progsrc.CancellationTokenSource.IsCancellationRequested)
    {
      MessageBox.Show("The operation was cancelled.");
    }
    return true;
  }
}&lt;/LI-CODE&gt;&lt;P&gt;The above sample code displays the progressbar like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_0-1683636758748.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/70221i2399C2B970115C7F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_0-1683636758748.png" alt="Wolf_0-1683636758748.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 13:07:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/progress-bar-status-trouble/m-p/1287213#M9792</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2023-05-09T13:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Progress bar status trouble</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/progress-bar-status-trouble/m-p/1287302#M9793</link>
      <description>Sounds like you are using some internal project bar related to the tool you are running, vs. one you wrote yourself. When you need full control of the bar use a System.Windows.Forms.ProgressBar on a WinForm . For example, here I'm loading a database into memory within an ArcGIS Pro addin.&lt;BR /&gt;[cid:image001.png@01D98250.8426CC30]&lt;BR /&gt;Code behind looks similar to this.&lt;BR /&gt;private Form myProgressBar;&lt;BR /&gt;public void LoadDatabase (SqlDataReader theDataSource)&lt;BR /&gt;{&lt;BR /&gt;if (myProgressBar==null)&lt;BR /&gt;{&lt;BR /&gt;myProgressBar = new wsdotCode.frmProgress();&lt;BR /&gt;}&lt;BR /&gt;System.Windows.Forms.ProgressBar pbar;&lt;BR /&gt;pbar = myProgressBar.Controls.Find("progressBar1", true).FirstOrDefault() as System.Windows.Forms.ProgressBar;&lt;BR /&gt;pbar.Value = 0;&lt;BR /&gt;myProgressBar.Show();&lt;BR /&gt;//increment the progress bar and read data&lt;BR /&gt;&lt;BR /&gt;While not EOF(theDataSource)&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;LoadRow(theDataSource)&lt;BR /&gt;&lt;BR /&gt;progressUpdate(pbar);&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;myProgressBar.Close();&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;private void progressUpdate(System.Windows.Forms.ProgressBar myBar)&lt;BR /&gt;{&lt;BR /&gt;//step size is set in the designer&lt;BR /&gt;myBar.PerformStep();&lt;BR /&gt;myBar.Refresh();&lt;BR /&gt;myBar.Parent.Refresh();&lt;BR /&gt;if (myBar.Value &amp;gt;= 100)&lt;BR /&gt;{&lt;BR /&gt;System.Threading.Thread.Sleep(200);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;System.Threading.Thread.Sleep(100);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}</description>
      <pubDate>Tue, 09 May 2023 15:45:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/progress-bar-status-trouble/m-p/1287302#M9793</guid>
      <dc:creator>RichardDaniels</dc:creator>
      <dc:date>2023-05-09T15:45:23Z</dc:date>
    </item>
  </channel>
</rss>

