< Summary - Kestrun — Combined Coverage

Information
Class: Public.Tasks.Stop-KrTask
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Tasks/Stop-KrTask.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 45
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 10/15/2025 - 01:01:18 Line coverage: 0% (0/3) Total lines: 45 Tag: Kestrun/Kestrun@7c4ce528870211ad6c2d2398c31ec13097fc5840

Metrics

Method
Stop-KrTask()

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Tasks/Stop-KrTask.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Requests cancellation for a running task.
 4.DESCRIPTION
 5    Signals the Kestrun Task service to cancel the specified task.
 6.PARAMETER Server
 7    The Kestrun server instance.
 8.PARAMETER Id
 9    Task id to cancel.
 10.PARAMETER WhatIf
 11    Shows what would happen if the cmdlet runs. The cmdlet is not run.
 12.PARAMETER Confirm
 13    Prompts you for confirmation before running the cmdlet.
 14.EXAMPLE
 15    Stop-KrTask -Id 'task-id'
 16    Requests cancellation for the specified task.
 17.NOTES
 18    Requires the Kestrun Task service to be added to the server via Add-KrTasksService.
 19    Cancellation is cooperative; the task script must periodically check for cancellation and stop itself.
 20    Returns $true if the task was found and cancellation was requested; $false if the task was not found or could not be
 21    If the task is already completed, cancellation will not be requested and $false will be returned.
 22    Cancellation may not be immediate; the task may take some time to stop after cancellation is requested.
 23    If the task does not support cancellation, it will continue to run until completion.
 24    This cmdlet supports ShouldProcess for confirmation prompts.
 25#>
 26function Stop-KrTask {
 27    [KestrunRuntimeApi('Everywhere')]
 28    [CmdletBinding(SupportsShouldProcess)]
 29    [OutputType([bool])]
 30    param(
 31        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 32        [Kestrun.Hosting.KestrunHost]$Server,
 33
 34        [Parameter(Mandatory)]
 35        [string]$Id
 36    )
 37    begin {
 038        $Server = Resolve-KestrunServer -Server $Server
 39    }
 40    process {
 041        if ($PSCmdlet.ShouldProcess("Task $Id", 'Cancel')) {
 042            return $Server.Tasks.Cancel($Id)
 43        }
 44    }
 45}

Methods/Properties

Stop-KrTask()