diff --git a/README.md b/README.md index 48c59a2..795c2dd 100644 --- a/README.md +++ b/README.md @@ -38,51 +38,140 @@ See the fully working examples below. Create a runspace. ``` -[ScriptBlock]$RunspaceDefinition = { - Param - ( - $SynchronizedHashtable, - $Title, - $Message - ) - - $Null = Add-Type -AssemblyName 'System.Windows.Forms' - $Null = Add-Type -AssemblyName 'System.Drawing' + [ScriptBlock]$RunspaceDefinition = { + Param + ( + $SynchronizedHashtable + ) + + [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 = [System.Collections.Hashtable]::Synchronized(@{}) - $SynchronizedHashtable.ThreadIDList = New-Object -TypeName 'System.Collections.Generic.List[System.String]' + + + + + + + -$InvokePSThreadParameters = New-Object -TypeName 'System.Collections.Specialized.OrderedDictionary' - $InvokePSThreadParameters.Runspace = $True - $InvokePSThreadParameters.RunspaceDefinition = $RunspaceDefinition - $InvokePSThreadParameters.RunspaceParameters = [Ordered]@{} - $InvokePSThreadParameters.RunspaceParameters.Title = "This is my UI title" - $InvokePSThreadParameters.RunspaceParameters.Message = "This is my UI message.`r`nThis is the second line of my UI message.`r`nThis is the third line of my UI message." - $InvokePSThreadParameters.SynchronizedHashtable = Get-Variable -Name 'SynchronizedHashtable' -ErrorAction SilentlyContinue - $InvokePSThreadParameters.FunctionList = Get-ChildItem -Path 'Function:' | Where-Object {($_.Name -iin @('Test'))} - $InvokePSThreadParameters.ModuleList = Get-Module | Where-Object {($_.Name -iin @('Test'))} - $InvokePSThreadParameters.VariableList = Get-Variable | Where-Object {($_.Name -iin @('Test'))} - $InvokePSThreadParameters.ContinueOnError = $False - $InvokePSThreadParameters.Verbose = $True + + + -$InvokePSThreadResult = Invoke-PSThread @InvokePSThreadParameters + -Write-Output -InputObject ($InvokePSThreadResult) + + + + + + + + + +'@ + + $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 '^