[System.Windows.Forms.Application]::DoEvents()

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 2 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
ClipperXTP
Posts: 55
Last visit: Thu Jun 24, 2021 3:05 am

[System.Windows.Forms.Application]::DoEvents()

Post by ClipperXTP »

Hi

Your thoughts on [System.Windows.Forms.Application]::DoEvents() and the below article?

https://www.sapien.com/blog/2011/07/15/ ... ive-loops/

It is a very old article and there is a lot of bad press about using [System.Windows.Forms.Application]::DoEvents()

My form and progress bar was not responsive when running a loop with a query of hundreds of machines using a runspacepool to do the leg work.

As soon as I inserted [System.Windows.Forms.Application]::DoEvents() in the loop, happy days, no freezing, progress bar and form are fine, I can even drag the form around the screen.
As long as I am disabling and re-enabling the buttons that trigger the query, is there any other considerations I need to have?

Thanks in advance
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: [System.Windows.Forms.Application]::DoEvents()

Post by jvierra »

Bad press? I read teh newspapers constantly. Never seen any press, good or bad, mention that.

Perhaps you are thinking about an old controversy from early days of VB where people would place a DoEvents after almost every line of code. You know, the old hack, if one pill is good than a thousand must be better.
ClipperXTP
Posts: 55
Last visit: Thu Jun 24, 2021 3:05 am

Re: [System.Windows.Forms.Application]::DoEvents()

Post by ClipperXTP »

Thank you
This topic is 2 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked