Handle a signal: Difference between revisions
Content added Content deleted
Simple9371 (talk | contribs) |
|||
Line 870: | Line 870: | ||
end handler; |
end handler; |
||
</lang> |
</lang> |
||
=={{header|PowerShell}}== |
|||
<lang powershell> |
|||
$Start_Time = (Get-date).second |
|||
Write-Host "Type CTRL-C to Terminate..." |
|||
$n = 1 |
|||
Try |
|||
{ |
|||
While($true) |
|||
{ |
|||
Write-Host $n |
|||
$n ++ |
|||
Start-Sleep -m 500 |
|||
} |
|||
} |
|||
Finally |
|||
{ |
|||
$End_Time = (Get-date).second |
|||
$Time_Diff = $End_Time - $Start_Time |
|||
Write-Host "Total time in seconds"$Time_Diff |
|||
} |
|||
</lang> |
|||
{{Out}} |
|||
<pre> |
|||
PS F:\> . .\signal.ps1 |
|||
Type CTRL-C to Terminate... |
|||
1 |
|||
2 |
|||
3 |
|||
4 |
|||
5 |
|||
Total time in seconds 2 |
|||
</pre> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
This code is for Windows only due to the usage of SetConsoleCtrlHandler() |
This code is for Windows only due to the usage of SetConsoleCtrlHandler() |