GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

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 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
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by angelofstealth »

Nevermind i found where they are and how to access them, sorry about that.
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by angelofstealth »

Sorry for the delay in response,

jvierra,
Based on looking at the imported control set, i have implemented it into my code. Back to my previous question about the properties for a control: In the PSS application if a user selects and sets a property manually through the properties pane is that information stored anywhere within the code of the form/project? Adding a built in controlset is great but doesn't give you the full settings applied to a control. I have attached my updated code/project/test, added logging and user notification to better understand if something breaks. Thanks,
Attachments
MainForm.psf
(73.25 KiB) Downloaded 131 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by jvierra »

You can create a new base control and compare it with the user control.
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by angelofstealth »

Okay sounds good, so it is manual then. Thanks
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by jvierra »

  1. PS>$b = [System.Windows.Forms.Button]::new()
  2. PS>$b.Location
  3.  
  4. IsEmpty X Y
  5. ------- - -
  6.    True 0 0
  7.  
  8.  
  9. PS>$b.Bounds
  10.  
  11.  
  12. Location : {X=0,Y=0}
  13. Size     : {Width=75, Height=23}
  14. X        : 0
  15. Y        : 0
  16. Width    : 75
  17. Height   : 23
  18. Left     : 0
  19. Top      : 0
  20. Right    : 75
  21. Bottom   : 23
  22. IsEmpty  : False
  23.  
  24.  
  25.  
  26. PS>$b.Size='50,200'
  27. PS>$b.Bounds
  28.  
  29.  
  30. Location : {X=0,Y=0}
  31. Size     : {Width=50, Height=200}
  32. X        : 0
  33. Y        : 0
  34. Width    : 50
  35. Height   : 200
  36. Left     : 0
  37. Top      : 0
  38. Right    : 50
  39. Bottom   : 200
  40. IsEmpty  : False
  1. PS>$b2 = [System.Windows.Forms.Button]::new()
  2. PS>$b.Location = '30,50'
  3. PS>compare $b $b2 -Property size,location,text,name
  4.  
  5.  
  6. size          : {Width=75, Height=23}
  7. location      : {X=0,Y=0}
  8. text          :
  9. name          :
  10. SideIndicator : =>
  11.  
  12. size          : {Width=50, Height=200}
  13. location      : {X=30,Y=50}
  14. text          :
  15. name          :
  16. SideIndicator : <=
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by angelofstealth »

Thanks jvierra, that helps a lot to understand the differences between the controls.

Question:

I am using the Add-tracker to go run a scriptblock which is pulling computer info remotely. If I want to pull from multiple computers should I only use one add-tracker and then in the scriptblock control the foreach computer loop. Or use the foreach loop and call the add-tracker within it to run. I think i should use separate trackers with different Jobs names and then wait for all jobs to complete, update form controls.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by jvierra »

The answer to that is completely up to you. It is a design consideration that cannot be made outside of knowing what you are trying to accomplish and what your design criteria are.
User avatar
angelofstealth
Posts: 69
Last visit: Wed Sep 28, 2022 10:04 am

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by angelofstealth »

What I am trying to understand is if i created a bunch of jobs for the Add-Jobtracker through a loop, how will the form stop from freezing or waiting to update the controls until all the jobs are done. If I use get-job | wait-job after my loop/added trackers, it seems i have a unresponsive form. If I do one computer object with one job i have no issue, want to let you know i do have that working. Understand the multithreading/multi jobs being done without freezing the form. Throwing this out there, don't know, would i use a add-jobtracker to then call on the computer objects loop which will in turn run the multiple job trackers.

Example:
$Computers = (Get-Content C:\Computers.txt)
Foreach ($Computer in $Computers)
{
$rlts = "ComputerInfo-$a"
Add-JobTracker -Name $rlts -JobScript $jobscript -CompletedScript $completedscript -UpdateScript $updatescript -ArgumentList $a, $b
}

Routine/high level:
1) read in a list of computer objects
2) Add to tracker and run script on local computer,
3) After each job completes it update arrays with the values in compeletdscript
4) Once all jobs are done updated datagrids with arrays full of all the data from the jobs.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: GUI: Progress Multiple Com Objects/Progress Bar - Responsive Form

Post by jvierra »

I can only recommend that JobTracker handles all of your concerns and can manage multiple jobs. Please read the full articles on JobTracker. They do a very good job of explaining how it works and how to use it.

If each script is lengthy then use multiple jobs. If the script is very short then one job. If there are a large number of computers then use multiple jobs.

Also study "Workflow" to see how to parallelize many computers in a single job.

help about_workflows
This topic is 6 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