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 7 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.
I am trying to understand the start job and how to update some textboxes and was hoping someone could help me out. I read through the tutorial understand the components but am having trouble writing it out.
I want to start a background job when I certain flag is set to "1" then stop or complete once it is "0". I also want to update some textboxes while the job is running.
I have this While statement that works but obviously freezes the the gui while running hence needing the job:
$current=$itunes.CurrentTrack |Select Name, Artist, Album
$textboxCurrentArtist.Text =$current.Artist
$textboxCurrentTrack.Text =$current.Name
$textboxCurrentAlbum.Text =$current.Album
Start-sleep-Seconds5
}
I would need the job to continue to loop while $itunes.PlayerState -eq "1" and update the 3 Textboxes every 5 seconds or so while the job is running. Once $itunes.PlayerState -eq "0" the job would complete.
OK, I think I am starting to get somewhere. I added what I did below but what happens is every 5 seconds it updates the textboxes but just flashes the correct text for not even a second then blanks the boxes, this obviously repeats every 5 seconds. Feels like I am making a stupid mistake.
and that seems to work adding the IF statement to ignore the Update if the data is the same I guess my question now is, is this the correct way to do this? Is there any downfall to having this loop every 5 seconds, will it cause any computer resource problems (memory/cpu usage) if it is looping for long periods of time? This will be running whenever we are listening to music.
BTW....love the Button – Start Job control set.....so may uses
sorry, I didn't see this until now. Does $itunes actually carry over to the job? In my standard shell script I define the com object inside the jobscript. I haven't tested the job tracker yet as I haven't wrapped my head around what to do with play/pause and skip.
This topic is 7 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.