I’m creating background jobs to perform a task.
I get certain values from a DataGridView
I’m adding the results in to another DGV and removing them from the source DGV.
I’m controlling the flow to limit the amount of background jobs running at one time.
everything works as expected but in the source i’m left with some items still in the source DGV after the loop that goes through each item in the source DGV.
The code for the button that executes the command is below:
I’d probably begin by putting a lot of Write-Verbose statements. Have it tell you what it’s pulling from the source grid, what it’s trying to delete, and so on. I’d probably also put some debug breakpoints in there - when it tells me it removed something, I’d also let it break so I could manually confirm the contents of the grid at that point.
I’m not going to be able to run your code, and it’s impossible to debug something like this statically. But the first debug step, in any situation, is to get the code to give you some information about what it’s doing. Analyze that output to make sure it’s what you expected it to be. If it isn’t, then you have some evidence of your bug.
I’m not great at debugging none console scripts/applications, I’ve been using things like [System.Windows.Forms.MessageBox]::Show($Error[0], “ERROR”) to give me details replacing the variable with want I want to view.
When I add the Write-Debug or Write-Verbose to the application i’m assuming the output will appear in the console portion of the PS Studios editor?
No offense but I’d start over with another form. Use one datagrid and update the cells based on the results. Your scannow button should execute for each row selected in the dgv. Use the job tracker function properly.
Here’s a stripped down example of how the jobtracker works. btw, sapien has forums as well.
write-host is the most efficient way of troubleshooting in the studio. Practice manipulating Cells and rows in the dgv, returning info etc. Get in the habit of building or binding datatables so you can use all the methods available.