I am having a problem with an install button and card not refreshing after doing an install of dedicated server files. the install goes well, the app will register the installed files, but the only way the card will update/refresh is if i manually reselect the current tab or restart the app. when i do that the button will switch to saying remove and when clicked it does uninstall the files, but again will not refresh back to saying install. Here is a portion of the code.
#Problem with buttons not refreshing after action
29 messages · Page 1 of 1 (latest)
what are the New-UGSM* cmdlets?
here are both files that go together hopefully this will help out. I have been at this for 2 days and have gotten nowhere. I been trying with refresh in all sorts of places again with no luck.
you got this on github in the full form?
the full app yes i do.
would be easier to just share the whole thing and link.
I can't see anything that would split the UI work from the thing that's acting. How have you implemented that in this code?
Does it matter if its private or not on github if i post the link here
it'll need to be public for us to look at it
when you do things like this: ```ps
$btnInstallSteam.Add_Click({
if ($callbackState.QueuePageRefresh) { & $callbackState.QueuePageRefresh }
that's a synchronous blocking action on the UI thread
here is the link https://github.com/KraziActiv/UGSM And I know i a lot of optimization to do in the app it far from being done.
none of that happens in the background, so none of your UI refreshes will actually show up until the event handler has finished
i left it sit for 10 minutes after the download and install was complete and the cards never refreshed. The only way the cards would refresh is if I clicked the games tab again or closed and reopened the app
I don't think it's a timing problem, there's a lot of places this could break and a lot that need debugging.
I haven't tested it, but I would be quite surprised if the BeginInvoke on your panel is actually working correctly.
PowerShell has rubbish support (aka none) for async UI operations. Everything is a game of working around it's significant limitations.
It's why when complex UIs come up the first answer is generally going to be "It's much easier to do this in C#".
if you do the UI layout and design there, nothing stops you hosting a PowerShell runspace to do the heavy lifting behind the UI
Well i was trying to keep things separate so it would be easier to find whatever you needed to find, i.e. to work on the settings tab i could just go to those files instead of scrolling through thousands of lines of code.
You kind of need a minimal reproducible example at this point that you can fix and take forward.
basically a case of make a form, add the panel, add the absolute minimum amount of stuff to do the refresh, retaining your refresh approach, and see if it still fails
I'd still take a strong bet on it all trying to run in the same thread, and potentially completely failing to run the refresh code entirely.
Yea i may have to do a complete rewrite of it. See about doing a possible combining of files to lessen call paths and what not
I wouldn't focus on the file layout
honestly other than making it a little slower (because files to read) that's barely a problem
the most common problem with UIs in PowerShell, given that PS is a bad language for them, is that you want two things to happen at once. The UI must respond, update, etc, and PS must do stuff to enact whatever it is your event handlers say.
What's hard here in PS is completely trivial in C#, hence the side-ways avenue for just doing the UI stuff there.
It's equally fine if you don't want to, you just have to deal a mass of work-arounds to make PS pretend.
A minimal reproducible sample would help a lot though, we can certainly help you debug that if you're stumped. Thousands of lines of code is too much though.
I'm afraid only have examples of things kind of thing using WPF. I never liked forms (too much code to write a basic UI vs a blob of XAML for WPF) so I didn't bother writing examples for it.
yeah i've always seen UI in powershell as near twice or more as hard as just learning c# because you have to know much more about the internals of c# and powershell
its okay, this is the 5 time I built this from the ground up. the first one was looking like it was from 1890. this was to try and have a nice updated ui
you may check out https://discord.com/channels/180528040881815552/1483091522323746837