mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fixing test run crash by not passing script block to the callback (#9298)
This commit is contained in:
committed by
Aditya Patwardhan
parent
98b2e147c1
commit
e299a30128
@@ -2915,6 +2915,9 @@ namespace System.Management.Automation
|
||||
/// </param>
|
||||
/// <param name="callback">
|
||||
/// An AsyncCallback to call once the BeginInvoke completes.
|
||||
/// Note: when using this API in script, don't pass in a delegate that is cast from a script block.
|
||||
/// The callback could be invoked from a thread without a default Runspace and a delegate cast from
|
||||
/// a script block would fail in that case.
|
||||
/// </param>
|
||||
/// <param name="state">
|
||||
/// A user supplied state to call the <paramref name="callback"/>
|
||||
@@ -3036,6 +3039,9 @@ namespace System.Management.Automation
|
||||
/// </param>
|
||||
/// <param name="callback">
|
||||
/// An AsyncCallback to call once the BeginInvoke completes.
|
||||
/// Note: when using this API in script, don't pass in a delegate that is cast from a script block.
|
||||
/// The callback could be invoked from a thread without a default Runspace and a delegate cast from
|
||||
/// a script block would fail in that case.
|
||||
/// </param>
|
||||
/// <param name="state">
|
||||
/// A user supplied state to call the <paramref name="callback"/>
|
||||
@@ -3158,6 +3164,9 @@ namespace System.Management.Automation
|
||||
/// </param>
|
||||
/// <param name="callback">
|
||||
/// An AsyncCallback to call once the command is invoked.
|
||||
/// Note: when using this API in script, don't pass in a delegate that is cast from a script block.
|
||||
/// The callback could be invoked from a thread without a default Runspace and a delegate cast from
|
||||
/// a script block would fail in that case.
|
||||
/// </param>
|
||||
/// <param name="state">
|
||||
/// A user supplied state to call the <paramref name="callback"/>
|
||||
@@ -3264,6 +3273,9 @@ namespace System.Management.Automation
|
||||
/// </param>
|
||||
/// <param name="callback">
|
||||
/// An AsyncCallback to call once the command is invoked.
|
||||
/// Note: when using this API in script, don't pass in a delegate that is cast from a script block.
|
||||
/// The callback could be invoked from a thread without a default Runspace and a delegate cast from
|
||||
/// a script block would fail in that case.
|
||||
/// </param>
|
||||
/// <param name="state">
|
||||
/// A user supplied state to call the <paramref name="callback"/>
|
||||
@@ -3733,6 +3745,9 @@ namespace System.Management.Automation
|
||||
/// </summary>
|
||||
/// <param name="callback">
|
||||
/// A AsyncCallback to call once the BeginStop completes.
|
||||
/// Note: when using this API in script, don't pass in a delegate that is cast from a script block.
|
||||
/// The callback could be invoked from a thread without a default Runspace and a delegate cast from
|
||||
/// a script block would fail in that case.
|
||||
/// </param>
|
||||
/// <param name="state">
|
||||
/// A user supplied state to call the <paramref name="callback"/>
|
||||
@@ -3794,6 +3809,9 @@ namespace System.Management.Automation
|
||||
/// </remarks>
|
||||
/// <param name="callback">
|
||||
/// An AsyncCallback to call once the command is invoked.
|
||||
/// Note: when using this API in script, don't pass in a delegate that is cast from a script block.
|
||||
/// The callback could be invoked from a thread without a default Runspace and a delegate cast from
|
||||
/// a script block would fail in that case.
|
||||
/// </param>
|
||||
/// <param name="state">
|
||||
/// A user supplied state to call the <paramref name="callback"/>
|
||||
|
||||
@@ -207,7 +207,7 @@ try {
|
||||
try {
|
||||
$ir = $ps.AddScript("Start-Sleep -Seconds 60").InvokeAsync()
|
||||
Wait-UntilTrue { $ps.InvocationStateInfo.State -eq [System.Management.Automation.PSInvocationState]::Running }
|
||||
$sr = $ps.StopAsync({}, $null)
|
||||
$sr = $ps.StopAsync($null, $null)
|
||||
[System.Threading.Tasks.Task]::WaitAll(@($sr))
|
||||
$sr.IsCompletedSuccessfully | Should -Be $true
|
||||
$ir.IsFaulted | Should -Be $true
|
||||
|
||||
Reference in New Issue
Block a user