Handle a signal: Difference between revisions
Content deleted Content added
demonstrate the power or signal handling |
No edit summary |
||
Line 460: | Line 460: | ||
main()</lang> |
main()</lang> |
||
=={{header|Gambas}}== |
|||
<lang gambas>hTimer As Timer |
|||
fTime As Float |
|||
Public Sub Application_Signal(x As Integer) |
|||
Print "Program stopped after " & fTime & " seconds" |
|||
Quit |
|||
End |
|||
Public Sub Main() |
|||
hTimer = New Timer As "IntTimer" |
|||
Print "Press [Ctrl] + " & Chr(92) & " to stop" |
|||
Signal[Signal.SIGQUIT].Catch |
|||
With hTimer |
|||
.Delay = 500 |
|||
.Start |
|||
End With |
|||
End |
|||
Public Sub IntTimer_Timer() |
|||
Print Rand(0, 100) |
|||
fTime += 0.5 |
|||
End</lang> |
|||
Output: |
|||
<pre> |
|||
Press [Ctrl] + \ to stop |
|||
29 |
|||
86 |
|||
67 |
|||
56 |
|||
46 |
|||
90 |
|||
0 |
|||
27 |
|||
94 |
|||
87 |
|||
40 |
|||
^\Program stopped after 5.5 seconds |
|||
</pre> |
|||
=={{header|Go}}== |
=={{header|Go}}== |