<?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 Show WinForm with ProgressBar while doing job in command. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3596304#M53583</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've some function in my command which calculating lots of data on dwg file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to show to user a WinForm with progress value. From the command I'm incrementing value of ProgressBar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that my ProgressBar is incrementing to the 100% after done all the job - suddendly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I can use some threading or backgroundWorker but it's hard for me and I didn't find any examples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Aug 2012 08:03:04 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-08-27T08:03:04Z</dc:date>
    <item>
      <title>Show WinForm with ProgressBar while doing job in command.</title>
      <link>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3596304#M53583</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've some function in my command which calculating lots of data on dwg file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to show to user a WinForm with progress value. From the command I'm incrementing value of ProgressBar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that my ProgressBar is incrementing to the 100% after done all the job - suddendly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I can use some threading or backgroundWorker but it's hard for me and I didn't find any examples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2012 08:03:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3596304#M53583</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-27T08:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Show WinForm with ProgressBar while doing job in command.</title>
      <link>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3596634#M53584</link>
      <description>&lt;P&gt;It&amp;nbsp;simple and straightforwaord&amp;nbsp;approch of showing progress bar on a form is to move the long processing logic into Form's code behind. However, this reduces code maintenanbility because it mixes the UI and data process code. This post might be useful to you:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://drive-cad-with-code.blogspot.ca/2010/12/showing-progress-window-when-running.html"&gt;http://drive-cad-with-code.blogspot.ca/2010/12/showing-progress-window-when-running.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2012 13:44:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3596634#M53584</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2012-08-27T13:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Show WinForm with ProgressBar while doing job in command.</title>
      <link>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3601602#M53585</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;AutoCAD has a built-in progress bar feature, have you looked at that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://through-the-interface.typepad.com/through_the_interface/2007/05/displaying_a_pr.html" target="_blank"&gt;http://through-the-interface.typepad.com/through_the_interface/2007/05/displaying_a_pr.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2012 14:44:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3601602#M53585</guid>
      <dc:creator>augusto.goncalves</dc:creator>
      <dc:date>2012-08-30T14:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: Show WinForm with ProgressBar while doing job in command.</title>
      <link>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3602072#M53586</link>
      <description>&lt;P&gt;if you don't need the UI to be responsive during the process (you don't have a Stop button, for example) then the easiest approach is moving the calculation to the UI thread&lt;/P&gt;&lt;P&gt;If you need the UI to be responsive, then look at this class&amp;nbsp;&lt;A href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" target="_blank"&gt;http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx&lt;/A&gt;&amp;nbsp;but don't forget to create thread-safe method for incrementing the progress bar.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2012 19:03:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3602072#M53586</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-30T19:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Show WinForm with ProgressBar while doing job in command.</title>
      <link>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3605140#M53587</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have just done what you want and it works!&lt;/P&gt;&lt;P&gt;First you have to init the min and max value of your ProgressBar, for instance iMin=0 and iMax=object.count&lt;/P&gt;&lt;P&gt;Then in your loop just add a line which increment the i value of the ProgressBar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;And the most essential is to upgrade your active form with the "Refresh" method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;'ProgressBar init'
Dim iMin As Long = 0
Dim iMax As Long

'Object Count'
Using acTrans = acDocs.MdiActiveDocument.Database.TransactionManager.StartTransaction()
      acBlkTbl = acTrans.GetObject(acDocs.MdiActiveDocument.Database.BlockTableId, OpenMode.ForRead)
      acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForRead)
      For Each acObjId As ObjectId In acBlkTblRec
          imax=iMax+1
      Next acObjId
End Using

ProgressBar1.Minimum= iMin
ProgressBar1.Maximum= iMax

'Iterate Through objects'
Dim i as Long
Using acTrans = acDocs.MdiActiveDocument.Database.TransactionManager.StartTransaction()
      acBlkTbl = acTrans.GetObject(acDocs.MdiActiveDocument.Database.BlockTableId, OpenMode.ForRead)
      acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForRead)
      For Each acObjId As ObjectId In acBlkTblRec

          'Your code'

          i=i+1                  
          ProgressBar1.Value = i          
          Me.Refresh 'Me=ActiveForm'
      Next acObjId
End Using&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Hope this may help you.&lt;/P&gt;&lt;P&gt;See you soon.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2012 14:10:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3605140#M53587</guid>
      <dc:creator>MGOMKD</dc:creator>
      <dc:date>2012-09-03T14:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: Show WinForm with ProgressBar while doing job in command.</title>
      <link>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3605520#M53588</link>
      <description>&lt;P&gt;I suggest refreshing just the ProgressBar&lt;/P&gt;&lt;P&gt;Instead of Me.Refresh use ProgressBar1.Refresh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had a lengthy operation and after a lot of optimalisation of the calculations, I found out, that half of the duration took the UI refreshing.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Sep 2012 06:40:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3605520#M53588</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-04T06:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Show WinForm with ProgressBar while doing job in command.</title>
      <link>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3646266#M53589</link>
      <description>&lt;P&gt;Yeah! refreshing progressing bar instead of the&amp;nbsp;form, is better!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See you.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2012 12:47:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/show-winform-with-progressbar-while-doing-job-in-command/m-p/3646266#M53589</guid>
      <dc:creator>MGOMKD</dc:creator>
      <dc:date>2012-10-04T12:47:35Z</dc:date>
    </item>
  </channel>
</rss>

