Skip to content

Commit

Permalink
refactor: 💥 rename module
Browse files Browse the repository at this point in the history
  • Loading branch information
anonhostpi committed Nov 2, 2023
1 parent 2efe852 commit ee33f29
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion New-ThreadController/New-ThreadController.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@{

# Script module or binary module file associated with this manifest.
RootModule = '.\New-DispatchThread.psm1'
RootModule = '.\New-ThreadController.psm1'

# Version number of this module.
ModuleVersion = '0.3.0'
Expand Down
9 changes: 4 additions & 5 deletions New-ThreadController/New-ThreadController.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function Update-DispatcherFactory {

Update-DispatcherFactory

function New-DispatchThread{
function New-ThreadController{
param(
[string] $Name = "Anonymous",
[hashtable] $SessionProxies = @{},
Expand Down Expand Up @@ -399,7 +399,7 @@ function Async {
if( $Threads[ $Thread ] ){
$Thread = $threads[ $Thread ]
} Else {
$Thread = New-DispatchThread -Name $Thread
$Thread = New-ThreadController -Name $Thread
}
} Else {
$Thread = $threads[ $Thread.Name ]
Expand Down Expand Up @@ -432,15 +432,14 @@ function Async {
}
}

# Export-ModuleMember -Function New-DispatchThread -Cmdlet New-DispatchThread
Export-ModuleMember `
-Function @(
"New-DispatchThread",
"New-ThreadController",
"Update-DispatcherFactory",
"Get-Threads",
"Async"
) -Cmdlet @(
"New-DispatchThread",
"New-ThreadController",
"Update-DispatcherFactory",
"Get-Threads",
"Async"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ PowerShell is an amazing language, but doesn't get all the love that C# does by
- This will add UWP APIs back into PowerShell Core on Windows
- Uses this workaround: https://github.com/PowerShell/PowerShell/issues/13042#issuecomment-653357546
- Adds significantly improved asynchronous code execution by providing runspace constructors that return a dispatcher
- `New-DispatchThread`
- `New-ThreadController`
- Readme coming soon...
20 changes: 10 additions & 10 deletions Test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ If( $ImportPackage ){
}

If( $NewDispatchThread ){
Import-Module "$Root\New-DispatchThread\"
Import-Module "$Root\New-ThreadController\"

# Should dump a warning followed by an error

Write-Host
Write-Host "--- New-DispatchThread:Avalonia"
Write-Host "--- New-ThreadController:Avalonia"
Update-DispatcherFactory ([Avalonia.Threading.Dispatcher])

# --- ThreadExtensions ---

Write-Host
Write-Host "--- New-DispatchThread:ThreadExtensions"
Write-Host "--- New-ThreadController:ThreadExtensions"
Update-DispatcherFactory ([ThreadExtensions.Dispatcher])

$t1 = New-DispatchThread
$t1 = New-ThreadController
$t1.Invoke({
Write-Host "Thread:" $ThreadName
Write-Host "test - ThreadExtensions:Un-named"
Expand All @@ -54,7 +54,7 @@ If( $NewDispatchThread ){
Write-Host

Try{
$t2 = New-DispatchThread -Name "Tester"
$t2 = New-ThreadController -Name "Tester"
$t2.Invoke({
Write-Host "Thread:" $ThreadName
Write-Host "test - ThreadExtensions:Named"
Expand All @@ -76,7 +76,7 @@ If( $NewDispatchThread ){
}
Write-Host

$anon1 = New-DispatchThread -Name "Anonymous"
$anon1 = New-ThreadController -Name "Anonymous"
(Async {
Write-Host "Thread:" $ThreadName
Write-Host "test - ThreadExtensions:Anon"
Expand All @@ -89,10 +89,10 @@ If( $NewDispatchThread ){
If( [System.Windows.Threading.Dispatcher] ){

Write-Host
Write-Host "--- New-DispatchThread:WPF"
Write-Host "--- New-ThreadControllerd:WPF"
Update-DispatcherFactory ([System.Windows.Threading.Dispatcher])

$t3 = New-DispatchThread
$t3 = New-ThreadController
$t3.Invoke({
Write-Host "Thread:" $ThreadName
Write-Host "test - WPF:Un-named"
Expand All @@ -101,7 +101,7 @@ If( $NewDispatchThread ){
Write-Host

Try{
$t4 = New-DispatchThread -Name "Tester"
$t4 = New-ThreadController -Name "Tester"
$t4.Invoke({
Write-Host "Thread:" $ThreadName
Write-Host "test - WPF:Named"
Expand All @@ -123,7 +123,7 @@ If( $NewDispatchThread ){
}
Write-Host

$anon2 = New-DispatchThread -Name "Anonymous"
$anon2 = New-ThreadController -Name "Anonymous"
(Async {
Write-Host "Thread:" $ThreadName
Write-Host "test - WPF:Anon"
Expand Down

0 comments on commit ee33f29

Please sign in to comment.