tag:blogger.com,1999:blog-993393844516183990.post834754851399313017..comments2024-03-24T13:53:19.219-07:00Comments on Drive AutoCAD with Code: Showing Progress Window When Running A Long ProcessNorman Yuanhttp://www.blogger.com/profile/09350392399498834066noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-993393844516183990.post-23961042393800955572011-06-01T08:52:00.816-07:002011-06-01T08:52:00.816-07:00Hi Norman,
thanks for your input, I wasn't a...Hi Norman, <br /><br />thanks for your input, I wasn't aware that updating the UI is so expensive.<br />Nonetheless I'll probably stick to your code, as firing the event only every 50th element, as I do, leads to an (for me) acceptable performance drop of around 15% (and as you pointed out, at least the user sees something happening).<br /><br />Regards, BerndAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-993393844516183990.post-88012300755690911532011-05-31T06:38:35.357-07:002011-05-31T06:38:35.357-07:00Bernd,
The drop of throughput is expected, becaus...Bernd,<br /><br />The drop of throughput is expected, because of the code to refresh progress window and call to System.Windows.Forms.Application.DoEvents(), as we know that updating window visually is a very expensive operation. <br /><br />If you use a window form to show progress as my code or similar, I am afraid this is the trade-off. Yes, you could reduce the the frequency of CommandProgress event being fired by only firing it every a few counts of items being processed, as you have already thought.<br /><br />Or, you may consider to use AutoCAD built-in progress showing mechnique - progress meter, which I guess should have much less impact on throughput.<br /><br />But do remember, visually showing progress of long process has big psycological effect to user: user would feel an actual slower, visual process is fast than a process that freezes the screen, even it is actaully faster.Norman Yuanhttps://www.blogger.com/profile/09350392399498834066noreply@blogger.comtag:blogger.com,1999:blog-993393844516183990.post-46223878508969196962011-05-31T05:23:45.889-07:002011-05-31T05:23:45.889-07:00Hi Norman,
thanks for your code, but in my applic...Hi Norman, <br />thanks for your code, but in my application this leads to a drop in throughput from almost 2000 elements per second to around 550 per second. I guess it has to do with having to instantiate the event handler over and over again. Isn't there a way to make this a bit more performant except of doing a <br />'if (CommandProgress != null && myCounter % 50 == 0)'?<br /><br />Regards, BerndAnonymousnoreply@blogger.com