Skip to content

Commit

Permalink
Removed unnecessary concurrent dictionary.
Browse files Browse the repository at this point in the history
  • Loading branch information
Exathi committed Mar 3, 2023
1 parent 50de697 commit dfdfcb4
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions Console Thread Start.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@ Add-Type -AssemblyName presentationframework, presentationcore
$DebugPreference = 'Continue'
. "$PSScriptRoot\Example.ps1"

# https://learn.microsoft.com/en-us/dotnet/standard/collections/thread-safe/
# Might as well since we're in this deep. Interchangable, no unique methods were used.
# [hashtable]::Synchronized(@{})
$script:syncHash = [System.Collections.Concurrent.ConcurrentDictionary[string, object]]::new()
$Window = New-WPFObject -Xaml $Xaml
# $Window.DataContext = [MainWindowViewModel]::new((New-RunspacePool))
$Window.DataContext = [MainWindowViewModelDP]::new((New-RunspacePool))

$state = New-InitialSessionState -VariableNames @('syncHash') #-StartUpScripts "$PSScriptRoot\Example.ps1"
$pool = New-RunspacePool -InitialSessionState $state
$syncHash.RSPool = $pool

$syncHash.Window = New-WPFObject -Xaml $Xaml
# $syncHash.Window.DataContext = [MainWindowViewModel]::new($syncHash.RSPool)
$syncHash.Window.DataContext = [MainWindowViewModelDP]::new($syncHash.RSPool)
# $application = [System.Windows.Application]::new()
# $application.ShutdownMode = [System.Windows.ShutdownMode]::OnMainWindowClose
# $null = $application.Run($syncHash.Window)
$syncHash.Window.ShowDialog()
$syncHash.Window.add_Closing($syncHash.Window.Dispatcher.InvokeShutdown())
$pool.Dispose()
$Window.add_Closing({
if ($Window.DataContext.RunspacePoolDependency) { $Window.DataContext.RunspacePoolDependency.Dispose() }
$Window.Dispatcher.InvokeShutdown()
})
$null = $Window.ShowDialog()

0 comments on commit dfdfcb4

Please sign in to comment.