Combobox causes crash/freeze

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 6 years and 8 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
User avatar
tvandenberghe@cochlear.com
Posts: 9
Last visit: Tue Sep 26, 2017 3:37 am

Combobox causes crash/freeze

Post by tvandenberghe@cochlear.com »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: Sapien Powershell Studio 2017
32 or 64 bit version of product:
Operating system: W10
32 or 64 bit OS:64bit

*** Please add details and screenshots as needed below. ***

I'm busy creating a script which ran fine this morning.
A couple of hours later, the application freezez/crashed when I select the combobox. (so before I'm able to select or type, the application freezes)

I get no errors... the app just freezes.

$button_DL_generateList = button used to populate my array $DL_all
$combo_DL_remove = my combobox



$button_DL_generateList_Click = {
$lbl_DL_loading.Visible = $true
$button_DL_generateList.Visible = $false

#put all active groups in array so group can be choosen from dropdown
$DL_all = @()
$DL_all = Get-DistributionGroup -Filter { (name -notlike "security-*") -and (name -notlike "security_*") } -ResultSize unlimited | select-object Name

$DL_all.getenumerator() |
foreach {
new-object psobject -Property @{ 'Name' = $_.name }
$combo_DL_remove.Items.Add($_.name)
}
$combo_DL_remove.Enabled = $true
$lbl_DL_loading.Visible = $false
$button_DL_generateList.Visible = $true
}
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Combobox causes crash/freeze

Post by davidc »

[TOPIC MOVED TO POWERSHELL GUIS FORUM BY MODERATOR]
David
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox causes crash/freeze

Post by jvierra »

Have you tried to run under the debugger to see what is blocking?

What changes did you make after the last time it ran successfully?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox causes crash/freeze

Post by jvierra »

Your code would be cleaner and faster if you do it like this:

Code: Select all

$button_DL_generateList_Click = {

	$lbl_DL_loading.Visible = $true
	$button_DL_generateList.Visible = $false
	
	#put all active groups in array so group can be choosen from dropdown
	$filter = {name -notlike 'security-*' -and name -notlike 'security_*' }
	$DL_all = Get-DistributionGroup -Filter $filter | select-object -expand Name
	$combo_DL_remove.Items.AddRange($DL_all)

	$combo_DL_remove.Enabled = $true
	$lbl_DL_loading.Visible = $false
	$button_DL_generateList.Visible = $true

}
User avatar
tvandenberghe@cochlear.com
Posts: 9
Last visit: Tue Sep 26, 2017 3:37 am

Re: Combobox causes crash/freeze

Post by tvandenberghe@cochlear.com »

@jvierra : it's cleaner for sure !

(I re-added the -ResultSize unlimited)

But still the app freezes when I click on the combo.
In debug : no errors are shown.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox causes crash/freeze

Post by jvierra »

tvandenberghe@cochlear.com wrote: Wed Jul 19, 2017 11:13 pm In debug : no errors are shown.
But where does it hang?
User avatar
tvandenberghe@cochlear.com
Posts: 9
Last visit: Tue Sep 26, 2017 3:37 am

Re: Combobox causes crash/freeze

Post by tvandenberghe@cochlear.com »

The code first populates the combobox.
When it has finished populating, the combobox becomes enabled.

As soon as you click on the combo to type, or when clicking on the small arrow to scroll : the app freezes, then after some seconds refreshes and the combobox is again empty. (=contains no values)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox causes crash/freeze

Post by jvierra »

How many items in the ComboBox? If there are thousands it will be very slow and seem to freeze. What other code is attached to the combo?
User avatar
tvandenberghe@cochlear.com
Posts: 9
Last visit: Tue Sep 26, 2017 3:37 am

Re: Combobox causes crash/freeze

Post by tvandenberghe@cochlear.com »

Before populating the combo
Pic_ 721.jpg
Pic_ 721.jpg (4.63 KiB) Viewed 2216 times
When the combo is populated
Pic_ 722.jpg
Pic_ 722.jpg (4.89 KiB) Viewed 2216 times
When the combo is selected to start typing
Pic_ 723.jpg
Pic_ 723.jpg (4.45 KiB) Viewed 2216 times
User avatar
tvandenberghe@cochlear.com
Posts: 9
Last visit: Tue Sep 26, 2017 3:37 am

Re: Combobox causes crash/freeze

Post by tvandenberghe@cochlear.com »

jvierra wrote: Thu Jul 20, 2017 1:56 am How many items in the ComboBox? If there are thousands it will be very slow and seem to freeze. What other code is attached to the combo?
-not 1 single event linked to this combo.
-changed my filtering so I get only 3 values. Populating the combo goes very fast now, but when selecting the combo the issue reoccurs. (freeze)
This topic is 6 years and 8 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