Skip to content

Commit

Permalink
Update Start-AsyncSQLQueryTest.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
MasayukiOzawa authored May 30, 2018
1 parent 0c1189a commit b974a06
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# http://tech.guitarrapc.com/entry/2013/10/29/100946
# http://tech.guitarrapc.com/entry/2013/10/29/100946
# https://www.gmo.jp/report/single/?art_id=195

# https://blogs.technet.microsoft.com/heyscriptingguy/2015/11/26/beginning-use-of-powershell-runspaces-part-1/
function Start-AsyncSQLQueryTest(){
[CmdletBinding()]
param
Expand All @@ -23,7 +23,6 @@ function Start-AsyncSQLQueryTest(){
$con = New-Object System.Data.SqlClient.SqlConnection
$con.ConnectionString = $ConnectionString
$con.Open()

$cmd = $con.CreateCommand()
$cmd.CommandType = [System.Data.CommandType]::Text
$cmd.CommandText = $Query
Expand All @@ -49,9 +48,8 @@ function Start-AsyncSQLQueryTest(){
$aryIAsyncResult = New-Object System.Collections.ArrayList
for ( $i = 0; $i -lt $RunspaceSize; $i++ )
{
$powershell = [PowerShell]::Create()
$powershell.RunspacePool = $runspacePool
$powershell = [PowerShell]::Create().AddScript($Command).AddArgument($ConnectionString).AddArgument($Query).AddArgument($CommandTimeout)
$powershell.RunspacePool = $runspacePool
[array]$RunspaceCollection += New-Object -TypeName PSObject -Property @{
Runspace = $powershell.BeginInvoke();
powershell = $powershell
Expand Down Expand Up @@ -87,4 +85,4 @@ $sw = [system.diagnostics.stopwatch]::startNew()
$sw | fl
$sw.Stop()

[System.Data.SqlClient.SqlConnection]::ClearAllPools()
[System.Data.SqlClient.SqlConnection]::ClearAllPools()

0 comments on commit b974a06

Please sign in to comment.