From 45bb0c029ae50789f8a8ebd97c320aad7b2fc9d7 Mon Sep 17 00:00:00 2001 From: freedbygrace Date: Tue, 24 Oct 2023 10:58:40 -0400 Subject: [PATCH] Update Invoke-PSThread.ps1 --- Invoke-PSThread.ps1 | 143 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 116 insertions(+), 27 deletions(-) diff --git a/Invoke-PSThread.ps1 b/Invoke-PSThread.ps1 index d6516fd..25fc52b 100644 --- a/Invoke-PSThread.ps1 +++ b/Invoke-PSThread.ps1 @@ -73,48 +73,137 @@ Function Invoke-PSThread [ScriptBlock]$RunspaceDefinition = { Param ( - $SynchronizedHashtable, - $Title, - $Message + $SynchronizedHashtable ) - - $Null = Add-Type -AssemblyName 'System.Windows.Forms' - $Null = Add-Type -AssemblyName 'System.Drawing' + + [System.Threading.Thread]::CurrentThread.Priority = [System.Threading.ThreadPriority]::Lowest + + $SynchronizedHashtable.UIDefinitionContent = @' + - $Form = New-Object -TypeName 'System.Windows.Forms.Form' - $Form.Size = New-Object -TypeName 'System.Drawing.Size' -ArgumentList @(300,150) - - $TextBox = New-Object -TypeName 'System.Windows.Forms.RichTextBox' - $TextBox.Location = New-Object -TypeName 'System.Drawing.Point' -ArgumentList @(110,50) - $TextBox.BorderStyle = 0 - $TextBox.BackColor = $Form.BackColor + + + + + + + - $TextBox.Text = $Message + + + + - $Null = $Form.Controls.Add($TextBox) + + - $Null = $Form.ShowDialog() - } + + + + + + + + + + + + + + + + + + + + + + + + + + +'@ + + $SynchronizedHashtable.UIDefinitionStringReader = New-Object -TypeName 'System.IO.StringReader' -ArgumentList @($SynchronizedHashtable.UIDefinitionContent) + + $SynchronizedHashtable.UIDefinitionXMLReader = [System.Xml.XmlReader]::Create($SynchronizedHashtable.UIDefinitionStringReader) + + $SynchronizedHashtable.UIDefinitionXMLDocument = New-Object -TypeName 'System.XML.XMLDocument' + $SynchronizedHashtable.UIDefinitionXMLDocument.LoadXML(($SynchronizedHashtable.UIDefinitionContent -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^ - [CmdletBinding(ConfirmImpact = 'Low', DefaultParameterSetName = 'Runspace', SupportsShouldProcess = $False)] + [CmdletBinding(ConfirmImpact = 'Low', DefaultParameterSetName = 'Runspace', PositionalBinding = $True)] Param ( - [Parameter(Mandatory=$False, ParameterSetName = 'Runspace')] + [Parameter(Position = 0, Mandatory=$False, ParameterSetName = 'Runspace')] [Alias('RS')] [Switch]$Runspace, - [Parameter(Mandatory=$False, ParameterSetName = 'RunspacePool')] + [Parameter(Position = 0, Mandatory=$False, ParameterSetName = 'RunspacePool')] [Alias('RP')] [Switch]$RunspacePool, - [Parameter(Mandatory=$False, ParameterSetName = 'Await')] + [Parameter(Position = 0, Mandatory=$False, ParameterSetName = 'Await')] [Alias('AW')] [Switch]$Await,