Example #1
0
        private void OnAwaked()
        {
            var eventArgs = new WakeUpEventArgs();
            OnWakeUp(eventArgs);

            Task.Run(async () =>
            {
                var timeout = Task.Delay(TimeSpan.FromSeconds(5));
                await Task.WhenAny(Task.WhenAll(eventArgs.WaitAll()), timeout);
                if (!timeout.IsCompleted)
                {
                    try
                    {
                        await Sleep();
                    }
                    catch
                    {
                        // NOP, device already sleeping
                    }
                }
            });
        }
Example #2
0
 protected virtual void OnWakeUp(WakeUpEventArgs e)
 {
     WakeUp?.Invoke(this, e);
 }