상속: LibuvSharp.Handle
예제 #1
0
파일: UVTimer.cs 프로젝트: txdv/LibuvSharp
 public static UVTimer Every(Loop loop, TimeSpan repeat, Action callback)
 {
     var timer = new UVTimer(loop);
     timer.Tick += callback;
     timer.Start(repeat, repeat);
     return timer;
 }
예제 #2
0
        public static UVTimer Every(Loop loop, TimeSpan repeat, Action callback)
        {
            var timer = new UVTimer(loop);

            timer.Tick += callback;
            timer.Start(repeat, repeat);
            return(timer);
        }
예제 #3
0
 public static void Main(string[] args)
 {
     Loop.Default.Run(async () => {
         var t = new UVTimer();
         var now = DateTime.Now;
         await t.StartAsync(TimeSpan.FromSeconds(1));
         Console.WriteLine(DateTime.Now - now);
     });
 }
예제 #4
0
	public static void Main(string[] args)
	{
		Loop.Default.Run(async () => {
			var t = new UVTimer();
			var stopwatch = Stopwatch.StartNew();
			await t.StartAsync(TimeSpan.FromSeconds(1));
			stopwatch.Stop();
			Console.WriteLine(stopwatch.Elapsed);
		});
	}
예제 #5
0
파일: StatusBar.cs 프로젝트: txdv/qutter
        public StatusBarTemplate(QuasselClient client)
        {
            Client = client;

            Client.BufferSyncer.Synced += (obj) => {
                Invalid = true;
            };

            var timer = new UVTimer();
            timer.Tick += () => Invalid = true;
            timer.Start(TimeSpan.Zero, TimeSpan.FromSeconds(1));
        }
예제 #6
0
        public static UVTimer Once(Loop loop, TimeSpan timeout, Action callback)
        {
            var timer = new UVTimer(loop);

            timer.Tick += () => {
                if (callback != null)
                {
                    callback();
                }
                timer.Close();
            };
            timer.Start(timeout, TimeSpan.Zero);
            return(timer);
        }
예제 #7
0
		public Fanbar(string root, int id)
		{
			Root = root;
			ID = id;
			Value = -1;

			timer = new UVTimer(Application.Loop);

			Get(PWM, (val) => {
				Invalid = true;
				Value = val;
			});


			timer.Start(TimeSpan.FromSeconds(1), () => {
				Get(FanInput, (val) => RPM = val);
			});
		}
예제 #8
0
        public static UVTimer Times(Loop loop, int times, TimeSpan repeat, Action <int> callback)
        {
            var timer = new UVTimer(loop);
            int i     = 0;

            timer.Tick += () => {
                i++;
                if (callback != null)
                {
                    callback(i);
                }
                if (i >= times)
                {
                    timer.Close();
                }
            };
            timer.Start(repeat, repeat);
            return(timer);
        }
예제 #9
0
        private static Action <Exception> End(TimeSpan timeSpan, Action <Exception> callback)
        {
            UVTimer timer = null;

            Action <Exception> end = (Exception exception) => {
                if (timer != null)
                {
                    timer.Close();
                    timer = null;
                    if (callback != null)
                    {
                        callback(exception);
                    }
                }
            };

            timer = UVTimer.Once(timeSpan, () => end(new TimeoutException()));

            return(end);
        }
예제 #10
0
파일: UVTimer.cs 프로젝트: txdv/LibuvSharp
 public static UVTimer Once(Loop loop, TimeSpan timeout, Action callback)
 {
     var timer = new UVTimer(loop);
     timer.Tick += () => {
         if (callback != null) {
             callback();
         }
         timer.Close();
     };
     timer.Start(timeout, TimeSpan.Zero);
     return timer;
 }
예제 #11
0
파일: UVTimer.cs 프로젝트: txdv/LibuvSharp
 public static UVTimer Times(Loop loop, int times, TimeSpan repeat, Action<int> callback)
 {
     var timer = new UVTimer(loop);
     int i = 0;
     timer.Tick += () => {
         i++;
         if (callback != null) {
             callback(i);
         }
         if (i >= times) {
             timer.Close();
         }
     };
     timer.Start(repeat, repeat);
     return timer;
 }