winutil/functions/public/Invoke-WPFRunspace.ps1
Chris Titus 3b133e704e
Test 2024 01 12 (#1401)
* change logseq url and add .net 8 (#1385)

* Update applications.json

Add Official logseq url 
Add .net runtime 8.0

* compile with new logseq and .net 8 runtime

* add thorium avx2

* Compile Winutil

* Remove Cider Music Player (#1400)

* Update winutil.ps1

* Update applications.json

* Compile Winutil

* Import/Export is now global, Settings menu added and many more improvements (#1398)

* Anoter one of those huge PRs
- Fix version inefficiency the version is already stored in sync, no need to slow down loading by one extra replace.
- Created custom dialog and About message
- Create a menu with Import/Export values
	- press on teh Settings cog in the right upper corner and save all the checkboxes
	- then you can either load them or load and run automatically
- Made Import Export load accross the whole app
- Optimized the way checkbox controls are looked up, it is 20% faster now
- Added a switch to load all the boxes from a config file
	- example: .winutil.ps1 -Config "C:UsersasdfDesktop\111.json"
- Added a switch to run all the action in unattended mode by passing -Run siwthc
	- example: .winutil.ps1 -Config "C:UsersasdfDesktop\111.json" -Run
	- This will run all the tweaks and install all the apps

* Fixing a couple of bugs and blur fonts, also menu now closes when focus is lost

---------

Co-authored-by: KonTy <KonTy@github.com>
Co-authored-by: Chris Titus <contact@christitus.com>

* Update applications.json

* Compile Winutil

* Add F8 Recovery Menu and Windows Reg Backup and others (#1389)

* Update feature.json append F8 legacy startup and Win Reg Backup and web search suggestion in search app

- enable automatic windows registry backup and do schedule for it as well (disabled by default in Win10, Win11) this will help when doing last known Good Configuration thru the F8 startup menu.
- enable / disable legacy F8 startup recovery option.
- enable / disable web search suggestions in the windows search in task bar.

* new tick boxes features. F8 recovery, regbackup, search web suggestions

- enable automatic windows registry backup and do schedule for it as well (disabled by default in Win10, Win11) this will help when doing last known Good Configuration thru the F8 startup menu.
- enable / disable legacy F8 startup recovery option.
- enable / disable web search suggestions in the windows search in task bar.

* Compile Winutil

* add Parsec to installable applications (#1157) (#1396)

Identifiers:
- Winget: Parsec.parsec
- Chocolatey: parsec

* Compile Winutil

* add Konty to About page

* Compile Winutil

* fix description (#1388) (#1402)

Co-authored-by: howell2024 <156375832+howell2024@users.noreply.github.com>

---------

Co-authored-by: Cristian Negulescu <cristian@clamsen.com>
Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com>
Co-authored-by: Tommi Pöntinen <98650216+hamburgerghini1@users.noreply.github.com>
Co-authored-by: KonTy <9524513+KonTy@users.noreply.github.com>
Co-authored-by: KonTy <KonTy@github.com>
Co-authored-by: Smartek <70715469+smartekIT@users.noreply.github.com>
Co-authored-by: Saikrishnan K <53394202+K-Saikrishnan@users.noreply.github.com>
Co-authored-by: howell2024 <156375832+howell2024@users.noreply.github.com>
2024-01-15 11:32:19 -06:00

49 lines
1.4 KiB
PowerShell

function Invoke-WPFRunspace {
<#
.SYNOPSIS
Creates and invokes a runspace using the given scriptblock and argumentlist
.PARAMETER ScriptBlock
The scriptblock to invoke in the runspace
.PARAMETER ArgumentList
A list of arguments to pass to the runspace
.EXAMPLE
Invoke-WPFRunspace `
-ScriptBlock $sync.ScriptsInstallPrograms `
-ArgumentList "Installadvancedip,Installbitwarden" `
#>
[CmdletBinding()]
Param (
$ScriptBlock,
$ArgumentList,
$DebugPreference
)
# Create a PowerShell instance
$script:powershell = [powershell]::Create()
# Add Scriptblock and Arguments to runspace
$script:powershell.AddScript($ScriptBlock)
$script:powershell.AddArgument($ArgumentList)
$script:powershell.AddArgument($DebugPreference) # Pass DebugPreference to the script block
$script:powershell.RunspacePool = $sync.runspace
# Execute the RunspacePool
$script:handle = $script:powershell.BeginInvoke()
# Clean up the RunspacePool threads when they are complete, and invoke the garbage collector to clean up the memory
if ($script:handle.IsCompleted)
{
$script:powershell.EndInvoke($script:handle)
$script:powershell.Dispose()
$sync.runspace.Dispose()
$sync.runspace.Close()
[System.GC]::Collect()
}
}