Beispiel #1
0
 public void EAPReadKeyFromKeyboardBufferAsync()
 {
     ThreadPool.QueueUserWorkItem(x =>
     {
         T _char = m_CriticalSection.ReadKeyFromKeyboardBuffer();
         ReadKeyFromKeyboardBufferCompleted?.Invoke(this, new InstanceCreationCompletedEventArgs <T>(_char));
     }
                                  );
 }
Beispiel #2
0
        public void ReadKeyFromKeyboardBufferAsyncUsingEAP()
        {
            char           _result         = default;
            AutoResetEvent _autoResetEvent = new AutoResetEvent(false);

            void _Callback(object state)
            {
                try
                {
                    _result = ReadKeyFromKeyboardBuffer();
                }
                finally
                {
                    _autoResetEvent.Set();
                }
            }

            ThreadPool.QueueUserWorkItem(_Callback);
            _autoResetEvent.WaitOne();
            _autoResetEvent.Close();
            ReadKeyFromKeyboardBufferCompleted?.Invoke(this, new ReadKeyFromKeyboardBufferCompletedEventArgs {
                Result = _result
            });
        }