本文整理汇总了C#中Mono.Unix.UnixSignal类的典型用法代码示例。如果您正苦于以下问题:C# UnixSignal类的具体用法?C# UnixSignal怎么用?C# UnixSignal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnixSignal类属于Mono.Unix命名空间,在下文中一共展示了UnixSignal类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
LogManager.LogFactory = new NLogFactory();
var appHost = new AppHost();
var appConfig = new TsonServiceConfig(args.Length > 0 ? args[0] : null, args.Length > 1 ? args[1] : null);
appHost.Container.Register<ITsonServiceConfig>(appConfig);
appHost.Init();
appHost.Start(appConfig.ServiceUrl);
UnixSignal[] signals = new UnixSignal[] {
new UnixSignal(Signum.SIGINT),
new UnixSignal(Signum.SIGTERM),
};
// Wait for a unix signal
for (bool exit = false; !exit;)
{
int id = UnixSignal.WaitAny(signals);
if (id >= 0 && id < signals.Length)
{
if (signals[id].IsSet)
exit = true;
}
}
}
开发者ID:jlyonsmith,项目名称:Tson,代码行数:27,代码来源:Program.cs
示例2: Main
static void Main(string[] args)
{
var oledType = Util.ChooseOLEDType();
Console.WriteLine($"Running test with selected display [{oledType}]");
Console.WriteLine("Hit CTRL+C to stop");
var wr = new Wrapper(oledType);
wr.SetTextColor(1);
wr.SetTextSize(2);
UnixSignal sigint = new UnixSignal(Mono.Unix.Native.Signum.SIGINT);
while (!sigint.IsSet)
{
wr.ClearDisplay();
wr.SetCursor(0, 0);
var str = $"{DateTime.Now.ToString("HH:mm.ss")}";
Console.WriteLine(str);
wr.Print(str);
wr.Display();
Thread.Sleep(1000);
}
}
开发者ID:ChriszGitHub,项目名称:ArduiPi_OLED,代码行数:26,代码来源:Program.cs
示例3: MultiThreadTest
// helper method to create a two-thread test
static void MultiThreadTest (UnixSignal signal, int timeout, ThreadStart tstart)
{
Thread t1 = CreateWaitSignalThread (signal, timeout);
Thread t2 = new Thread (tstart);
t1.Start ();
t2.Start ();
t1.Join ();
t2.Join ();
}
开发者ID:handyyuan,项目名称:playscript,代码行数:10,代码来源:UnixSignalTest.cs
示例4: TestWaitAnyFailsWithMore64Signals
public void TestWaitAnyFailsWithMore64Signals()
{
UnixSignal s1 = new UnixSignal(Signum.SIGINT);
UnixSignal[] signals = new UnixSignal[65];
for (int i=0; i<65; ++i)
signals[i] = s1;
Assert.That(UnixSignal.WaitAny(signals, new TimeSpan(0,0,1)), Is.EqualTo(-1));
}
开发者ID:handyyuan,项目名称:playscript,代码行数:9,代码来源:UnixSignalTest.cs
示例5: WaitForUnixStopSignal
static void WaitForUnixStopSignal()
{
UnixSignal[] signals = new UnixSignal[]
{
new UnixSignal(Signum.SIGINT),
new UnixSignal(Signum.SIGTERM)
};
UnixSignal.WaitAny(signals);
}
开发者ID:mageomageos,项目名称:animerecs,代码行数:9,代码来源:Program.cs
示例6: Main
static void Main(string[] args)
{
//Set up IO - (TODO, allow to be set in config file)
var RingerPower = new Raspberry.IO.GeneralPurpose.OutputPinConfiguration (Raspberry.IO.GeneralPurpose.ProcessorPin.Pin17);
var RingerOscillator = new Raspberry.IO.GeneralPurpose.OutputPinConfiguration (Raspberry.IO.GeneralPurpose.ProcessorPin.Pin18);
var HookSwitch = new Raspberry.IO.GeneralPurpose.InputPinConfiguration (Raspberry.IO.GeneralPurpose.ProcessorPin.Pin22)
{
Reversed = true
};
var DialPulseSwitch = new Raspberry.IO.GeneralPurpose.InputPinConfiguration (Raspberry.IO.GeneralPurpose.ProcessorPin.Pin27);
//Start Ringer and DialListener GPIO classes
using (var ringer = new clsRinger (RingerPower, RingerOscillator))
{
using (var dialListener = new clsDialHookListener(HookSwitch,DialPulseSwitch))
{
//Simple bell test function. 0 = UK ring, 1 = USA Ring
dialListener.NumberDialed += (uint NumberDialed) =>
{
Console.WriteLine("Number Dialed:{0}",NumberDialed);
if (NumberDialed == 0) {
ringer.SetRingPattern (clsRinger.ringPattern_UK);
ringer.StartRing ();
} else if (NumberDialed == 9) {
ringer.SetRingPattern (clsRinger.ringPattern_USA);
ringer.StartRing ();
}
};
//Cancel the Ringer
dialListener.HookSwitchChange += (bool OnHook, uint Pulse) =>
{
if (!OnHook)
ringer.StopRing ();
};
UnixSignal[] signals = new UnixSignal [] {
new UnixSignal (Mono.Unix.Native.Signum.SIGINT),
new UnixSignal (Mono.Unix.Native.Signum.SIGUSR1),
};
while (true)
{
int index = UnixSignal.WaitAny (signals, -1); //Wait for any Unix Signals
Mono.Unix.Native.Signum signal = signals [index].Signum;
Console.Write("SIGNAL:{0}",signal.ToString());
break;
}
;
}
}
Console.WriteLine ("**end**");
}
开发者ID:logicethos,项目名称:PiTelephone,代码行数:57,代码来源:Program.cs
示例7: Main
public static int Main (string[] args)
{
using (ServiceHost host = new ServiceHost (typeof (HangmanService)))
{
var security = new SecurityMode ();
host.AddServiceEndpoint (
typeof(IHangmanService),
new WSHttpBinding (security, true),
"http://localhost:8325/");
host.Open ();
/*
Console.WriteLine ("Type [CR] to stop ...");
Console.ReadKey ();
*/
/* Demon */
UnixSignal sigint = new UnixSignal (Signum.SIGINT);
UnixSignal sigterm = new UnixSignal (Signum.SIGTERM);
UnixSignal sighup = new UnixSignal (Signum.SIGHUP);
UnixSignal sigusr2 = new UnixSignal (Signum.SIGUSR2);
UnixSignal [] signals = new UnixSignal[]
{
sigint,
sigterm,
sighup,
sigusr2
};
bool exit = false;
while (!exit)
{
int id = UnixSignal.WaitAny (signals);
if (id >= 0 && id < signals.Length)
{
if (sigint.IsSet || sigterm.IsSet)
{
sigint.Reset ();
sigterm.Reset ();
exit = true;
} else if (sighup.IsSet)
sighup.Reset ();
else if (sigusr2.IsSet)
sighup.Reset ();
}
}
/* Demon */
host.Close ();
}
return 0;
}
开发者ID:dms-cmt,项目名称:hangman-service,代码行数:56,代码来源:Program.cs
示例8: SignalHandler
public static void SignalHandler()
{
var sig = new UnixSignal( Mono.Unix.Native.Signum.SIGUSR2 );
var sigs = new UnixSignal[] { sig };
do {
UnixSignal.WaitAny( sigs, new TimeSpan(0,1,0) );
covertool.SaveData();
} while ( debugee != null && !debugee.HasExited );
}
开发者ID:Money520,项目名称:XR.Baboon,代码行数:10,代码来源:Program.cs
示例9: InitSignals
static void InitSignals()
{
UnixSignal term = new UnixSignal (Mono.Unix.Native.Signum.SIGTERM);
UnixSignal inter = new UnixSignal (Mono.Unix.Native.Signum.SIGINT);
GLib.Timeout.Add (500, delegate {
if (term.IsSet || inter.IsSet)
Application.Quit ();
return true;
});
}
开发者ID:garuma,项目名称:zencomic,代码行数:12,代码来源:Main.cs
示例10: CreateWaitSignalThread
// helper method to create a thread waiting on a UnixSignal
static Thread CreateWaitSignalThread (UnixSignal signal, int timeout)
{
Thread t1 = new Thread(delegate() {
DateTime start = DateTime.Now;
bool r = signal.WaitOne (timeout, false);
DateTime end = DateTime.Now;
Assert.AreEqual (signal.Count, 1);
Assert.AreEqual (r, true);
if ((end - start) > new TimeSpan (0, 0, timeout/1000))
throw new InvalidOperationException ("Signal slept too long");
});
return t1;
}
开发者ID:handyyuan,项目名称:playscript,代码行数:14,代码来源:UnixSignalTest.cs
示例11: LinuxHandler
private void LinuxHandler()
{
Log.Notice("Linux", "Initializing Handler for SIGINT, SIGHUP");
var signals = new UnixSignal[]
{
new UnixSignal(Signum.SIGINT),
new UnixSignal(Signum.SIGHUP)
};
int which = UnixSignal.WaitAny(signals, -1);
Log.Debug("Linux", "Got a {0} signal!", signals[which].Signum);
Log.Notice("Linux", "Handler Terminated.");
MainClass.Shutdown();
}
开发者ID:Schumix,项目名称:Schumix2,代码行数:14,代码来源:Linux.cs
示例12: TestNestedInvocation
public void TestNestedInvocation()
{
UnixSignal s = new UnixSignal(Signum.SIGINT);
Thread a = new Thread(delegate() {
bool r = s.WaitOne (1000, false);
});
Thread b = new Thread(delegate() {
bool r = s.WaitOne (500, false);
});
a.Start();
b.Start();
a.Join();
b.Join();
}
开发者ID:handyyuan,项目名称:playscript,代码行数:14,代码来源:UnixSignalTest.cs
示例13: LinuxHandler
protected virtual void LinuxHandler()
{
Log.Notice("Linux", sLConsole.GetString("Initializing Handler for SIGINT, SIGHUP"));
var signals = new UnixSignal[]
{
new UnixSignal(Signum.SIGINT),
new UnixSignal(Signum.SIGHUP)
};
int which = UnixSignal.WaitAny(signals, -1);
Log.Debug("Linux", sLConsole.GetString("Got a {0} signal."), signals[which].Signum);
Log.Notice("Linux", sLConsole.GetString("Handler Terminated."));
Action();
}
开发者ID:Schumix,项目名称:Schumix2,代码行数:14,代码来源:DefaultLinux.cs
示例14: UnixExitSignal
public UnixExitSignal()
{
UnixSignal[] signals = new UnixSignal[]
{
new UnixSignal(Signum.SIGTERM),
new UnixSignal(Signum.SIGINT),
new UnixSignal(Signum.SIGUSR1),
};
Task.Factory.StartNew(() =>
{
int index = UnixSignal.WaitAny(signals, Timeout.Infinite);
if (Signaled != null)
Signaled(this, EventArgs.Empty);
});
}
开发者ID:pferraris,项目名称:DockerServices,代码行数:15,代码来源:UnixExitSignal.cs
示例15: Attach
internal static void Attach(Entry plugin)
{
if (Tools.RuntimePlatform != OTA.Misc.RuntimePlatform.Microsoft)
{
try
{
if (!_attached)
{
_attached = true;
// Catch SIGINT, SIGUSR1 and SIGTERM
UnixSignal[] signals = new UnixSignal[]
{
new UnixSignal(Signum.SIGINT),
new UnixSignal(Signum.SIGUSR1),
new UnixSignal(Signum.SIGTERM)
};
(signal_thread = new Thread(delegate ()
{
System.Threading.Thread.CurrentThread.Name = "SIG";
while (!Terraria.Netplay.disconnect && _attached)
{
// Wait for a signal to be delivered
var index = UnixSignal.WaitAny(signals, -1);
var signal = signals[index].Signum;
if (!Terraria.Netplay.disconnect && _attached)
{
_attached = false;
OTA.Logging.ProgramLog.Log("Server received Exit Signal");
VanillaCommands.Exit(null, null);
}
}
})).Start();
}
OTA.Logging.ProgramLog.Log("Server can accept SIGTERM");
}
catch
{
OTA.Logging.ProgramLog.Log("Failed to attatch SIGTERM listener");
}
}
}
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:44,代码来源:Sigterm.cs
示例16: TestConcurrentWaitOne
public void TestConcurrentWaitOne()
{
UnixSignal s1 = new UnixSignal(Signum.SIGINT);
UnixSignal s2 = new UnixSignal(Signum.SIGINT);
Thread a = CreateWaitSignalThread(s1, 10000);
Thread b = CreateWaitSignalThread(s2, 5000);
Thread c = new Thread (delegate () {
Thread.Sleep (1000);
Stdlib.raise (Signum.SIGINT);
});
a.Start();
b.Start();
c.Start();
a.Join();
b.Join();
c.Join();
Assert.That(s1.Count, Is.EqualTo(1), "Expected 1 signal raised");
Assert.That(s2.Count, Is.EqualTo(1), "Expected 1 signal raised");
}
开发者ID:handyyuan,项目名称:playscript,代码行数:19,代码来源:UnixSignalTest.cs
示例17: Program
/// <summary>
/// Creates instance of program.
/// </summary>
private Program()
{
AssemblyName asm = Assembly.GetExecutingAssembly().GetName();
new Gnome.Program(asm.Name, asm.Version.ToString(), Gnome.Modules.UI, new string[0]);
Gnome.Global.MasterClient().SaveYourself += this.OnSaveYourself;
Gnome.Global.MasterClient().Die += this.OnDie;
ThreadPool.QueueUserWorkItem((o) =>
{
UnixSignal[] signals = new UnixSignal[] { new UnixSignal(Signum.SIGTERM), new UnixSignal(Signum.SIGINT) };
UnixSignal.WaitAny(signals);
Gtk.Application.Invoke((s, args) =>
{
this.OnSaveYourself(this, null);
this.OnDie(this, null);
});
});
Glippy.Application.Application.Initialize();
}
开发者ID:quequotion,项目名称:glippy,代码行数:23,代码来源:Program.cs
示例18: Main
public static void Main(string[] args)
{
new AppHost(args.Length == 0).Init().Start("http://*:9832/");
"ServiceStack is listening".Print();
UnixSignal [] signals = new UnixSignal[] {
new UnixSignal(Signum.SIGINT),
new UnixSignal(Signum.SIGTERM),
};
// Wait for a unix signal
for (bool exit = false; !exit; )
{
int id = UnixSignal.WaitAny(signals);
if (id >= 0 && id < signals.Length)
{
if (signals[id].IsSet) exit = true;
}
}
}
开发者ID:blakeblackshear,项目名称:npgsql-ssl-connection-issues,代码行数:20,代码来源:Program.cs
示例19: SignalWatcher
public SignalWatcher(Context context, Signum[] signals, Action<Signum> callback)
{
Signals = signals;
unixSignals = new UnixSignal[signals.Length];
for (int i = 0; i < signals.Length; i++) {
unixSignals[i] = new UnixSignal(signals[i]);
}
watcher = new AsyncWatcher<Signum>(context, (key) => {
if (callback != null) {
callback(key);
}
});
thread = new Thread((o) => {
while (true) {
var index = UnixSignal.WaitAny(unixSignals);
watcher.Send(Signals[index]);
}
});
}
开发者ID:txdv,项目名称:Mono.Terminal,代码行数:21,代码来源:SignalWatcher.cs
示例20: Main
public static void Main(string[] args)
{
// Set default and see if Heroku is defining something for us...
int port = 8080;
var herokuPort = Environment.GetEnvironmentVariable ("PORT");
var mode = "web";
if(!String.IsNullOrEmpty(herokuPort))
{
port = Convert.ToInt32 (herokuPort);
}
if (args.Length > 0)
{
mode = args [0];
}
// bootstrap everything and start hosting...
var url = "http://*:{0}/".Fmt(port);
Console.WriteLine("Listening on: {0}".Fmt(url));
var appHost = new AppHost(mode);
appHost.Init();
appHost.Start(url);
UnixSignal[] signals = new UnixSignal[] {
new UnixSignal(Signum.SIGINT),
new UnixSignal(Signum.SIGTERM),
};
// Wait for a unix signal
for (bool exit = false; !exit; )
{
int id = UnixSignal.WaitAny(signals);
if (id >= 0 && id < signals.Length)
{
if (signals[id].IsSet) exit = true;
}
}
}
开发者ID:nover,项目名称:service-stack-selfhost-heroku,代码行数:40,代码来源:Program.cs
注:本文中的Mono.Unix.UnixSignal类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论