/// <summary> /// Create Porling Process /// </summary> private void initToken() { // start event porling IntervalUtil.Start(TimeSpan.FromMilliseconds(5), () => { killproc(); // remove kill requested features if (_tokenQueue.Count > 0) { var sw = Stopwatch.StartNew(); while (TokenEventProc() > 0) { killproc(); // remove kill requested features if (sw.ElapsedMilliseconds > 20000) { LOG.AddException(new TimeoutException("Token Loop timeout (It is possible infinity token loop)")); break; } } // Exec Finalizer var ics = finalizeActions.ToArray(); finalizeActions.Clear(); foreach (var act in ics) { act.Invoke(); } // all tokens are execed here. Fire the TokenLoop Event TokenLoop?.Invoke(this, EventArgs.Empty); } CheckInvalidateReqested(); }); }
private void InitKeyboard() { var win = Window.Current.CoreWindow; win.KeyDown += OnKeyDown; win.KeyUp += OnKeyUp; IntervalUtil.Start(TimeSpan.FromMilliseconds(2347), () => { // make virtual key up event when out of window focus (and key was released) foreach (var key in _keys.Where(kv => kv.Value).Select(kv => kv.Key).ToArray()) { var ks = Window.Current.CoreWindow.GetKeyState(key); if ((ks & CoreVirtualKeyStates.Down) == 0) // no longer press { KeyUpProc(key); } } }); }