get-childitem combobox

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 3 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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: get-childitem combobox

Post by jvierra »

If you are only looking for something that says "Here is an example of how to do blah" then you will have much difficulty with PowerShell and programming. Documentation needs to be understood and then tested until you understand how any command or API work. This is just something we all have to learn when adventuring into the more technical side of programming. There is no way to generate documentation that will account for every possible usage of a command or API call.

The control set was delivered as an example of a way to manage multiple jobs in a form. It works well as documented in the article. Understanding how it works is critical. Learning how to explore and understand all parameters for a CmdLet is critical to programming PowerShell.

Believe me. I have taught many experienced programmers to program forms. They run into the same frustration because they assume that this advanced system is as simple as old VB6 or early C programming. It isn't. Modern programming APIs are very complex. You must take extra time to learn each control and CmdLet you are wanting to use. You will seldom get exact examples for your issues.
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: get-childitem combobox

Post by apowershelluser »

I also want to be very clear about something. I am very fortunate for each of you responding to my post, please know that first and foremost.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: get-childitem combobox

Post by davidc »

The Add-JobTracker's ArgumentList parameter is passed directly to Start-Job cmdlet.
See:
https://docs.microsoft.com/en-us/powers ... rshell-5.1

If you want to support multiple arguments, then simply pass them via the ArgumentList parameter (comma delimited) and update the parameter block of the JobScript to reflect the number of arguments:
  1. Add-JobTracker -Name 'JobName' -JobScript{
  2. param($Param1, $Param2) #Update the parameter block
  3. } -ArgumentList $param1Value, $param2Value
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: get-childitem combobox

Post by jvierra »

I think what seems to continue to confuse with this control set is that there are two items that seem to be similar. While the blog article explains this well most users are no experienced technical readers and tend to skim for answers.

Start-Job is a PowerShell core CmdLet. Add-JobTracker is a Sapien function that manages the setup of the jobs. The arguments for Add-JobTracker store the scriptblocks for update and complete and pass the "-JobScript" to the Start-Job CmdLet. Understanding how to use PS jobs is a prerequisite for using this control set. I recommend designing and testing the job script as a PS1 fil or just pasted into the console until it behaves as needed. This will separate out issues with the script, understanding of jobs and code isolation issues. Remember that a job runs in a separate process and cannot "see" variables in the caller. This is all PowerShell related and has little to do with the JobTracker control. The control set just automates the running of jobs such that they can be monitored without freezing the form.
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: get-childitem combobox

Post by apowershelluser »

These are both extremely helpful. I also appreciate the extra examples on how to go about this. For this project I only have one other question and I'm going to do my best to figure it out myself

It deals with a radiobutton and the $result from the completed script
This topic is 6 years and 3 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