当前位置: 首页>>代码示例>>C#>>正文


C# UnixSignal.WaitOne方法代码示例

本文整理汇总了C#中Mono.Unix.UnixSignal.WaitOne方法的典型用法代码示例。如果您正苦于以下问题:C# UnixSignal.WaitOne方法的具体用法?C# UnixSignal.WaitOne怎么用?C# UnixSignal.WaitOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Unix.UnixSignal的用法示例。


在下文中一共展示了UnixSignal.WaitOne方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: TestNoEmit

		public void TestNoEmit ()
		{
			using (UnixSignal u = new UnixSignal (Signum.SIGINT)) {
				DateTime start = DateTime.Now;
				bool r = u.WaitOne (5100, false);
				Assert.AreEqual (r, false);
				DateTime end = DateTime.Now;
				if ((end - start) < new TimeSpan (0, 0, 5))
					throw new InvalidOperationException ("Signal didn't block for 5s; blocked for " + (end-start).ToString());
			}
		}
开发者ID:handyyuan,项目名称:playscript,代码行数:11,代码来源:UnixSignalTest.cs

示例4: TestRaise

		public void TestRaise ()
		{
			Thread t1 = new Thread (delegate () {
					using (UnixSignal a = new UnixSignal (Signum.SIGINT)) {
						DateTime start = DateTime.Now;
						bool r = a.WaitOne (5000, false);
						DateTime end = DateTime.Now;
						Assert.AreEqual (a.Count, 1);
						Assert.AreEqual (r, true);
						if ((end - start) > new TimeSpan (0, 0, 5))
							throw new InvalidOperationException ("Signal slept too long");
					}
			});
			Thread t2 = new Thread (delegate () {
					Thread.Sleep (1000);
					Stdlib.raise (Signum.SIGINT);
			});
			t1.Start ();
			t2.Start ();
			t1.Join ();
			t2.Join ();
		}
开发者ID:handyyuan,项目名称:playscript,代码行数:22,代码来源:UnixSignalTest.cs

示例5: SetControlCHandler

        internal static void SetControlCHandler()
        {
            if (Utilities.IsWindows)
            {
                if (!_windowsConsoleHandlerSet)
                    Console.CancelKeyPress += ConsoleControlCHandler;

                _windowsConsoleHandlerSet = true;
            }
            else if (_signalThread == null)
            {
                Stdlib.SetSignalAction(Signum.SIGINT, SignalAction.Default);

                _signalThread = new Thread(() =>
                {
                    try
                    {
                        using (var sig = new UnixSignal(Signum.SIGINT))
                        {
                            while (true)
                            {
                                sig.WaitOne();

                                ControlCHandler();
                            }
                        }
                    }
                    catch (ThreadAbortException)
                    {
                    }
                });

                _signalThread.Start();
            }
        }
开发者ID:techcap,项目名称:sdb,代码行数:35,代码来源:CommandLine.cs

示例6: Main

 static void Main()
 {
     Program.Games = new Dictionary<int, Game>();
     dump_fname = Environment.GetEnvironmentVariable("OPENSHIFT_DATA_DIR")+"games.dump";
     log_fname = Environment.GetEnvironmentVariable("OPENSHIFT_DIY_LOG_DIR") + "errors.log";
     string data_dir = Environment.GetEnvironmentVariable("OPENSHIFT_DATA_DIR");
     if (data_dir != null) {
         System.IO.TextReader file = new System.IO.StreamReader(data_dir+"secret_token.txt", true);
         SECRET = file.ReadToEnd();
         file.Close();
     }
     if (System.IO.File.Exists(dump_fname))
     {
         System.IO.TextReader file = new System.IO.StreamReader(dump_fname, true);
         string[] f = file.ReadToEnd().Split(new string[]{"\n"},StringSplitOptions.RemoveEmptyEntries);
         foreach (string el in f)
         {
             string[] s = el.Split('@');
             Program.Games.Add(int.Parse(s[0]),JsonConvert.DeserializeObject<Game>(s[1]));
         }
         file.Close();
     }
     try
     {
         WebSocket.Start();
     }
     catch (Exception e)
     {
         Log("Startup fatal error: "+e.ToString());
         System.Environment.Exit(0);
     }
     Log("Start");
     UnixSignal term = new UnixSignal(Signum.SIGTERM);
     term.WaitOne();
     Log("Terminate");
     SaveGame();
     System.Environment.Exit(0);
 }
开发者ID:nzinov,项目名称:fizteh-seabattle,代码行数:38,代码来源:Program.cs


注:本文中的Mono.Unix.UnixSignal.WaitOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。