Created
January 3, 2012 15:05
-
-
Save jonpryor/1555261 to your computer and use it in GitHub Desktop.
Mono.Unix.UnixSignal example app; see http://www.jprl.com/Blog/archive/development/mono/2008/Feb-08.html#comment-399526948
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using Mono.Unix; | |
using Mono.Unix.Native; | |
class Test { | |
static void Main () | |
{ | |
StartHandler(); | |
Console.WriteLine("Press any key to exit..."); | |
Console.ReadLine(); | |
} | |
static void StartHandler() | |
{ | |
new Thread(TerminateHandler).Start(); | |
} | |
static void TerminateHandler() | |
{ | |
Console.WriteLine("Initializing Handler for SIGINT"); | |
UnixSignal signal = new UnixSignal(Signum.SIGINT); | |
while(signal.WaitOne()) | |
{ | |
Console.WriteLine("Control-C Pressed!"); | |
break; | |
} | |
Console.WriteLine("handler Terminated"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What about if I want to handle multiple instances of the same signal?