Пример #1
0
        public void SetStrokeZone(byte min, byte max)
        {
            if (max == 99)
            {
                max = 100;
            }

            lock (_updateRangeLock)
            {
                _newZone = new HandySetStrokeZone
                {
                    timeout = 4000,
                    min     = min,
                    max     = max
                };

                _resetRangeTask = true;

                if (!_updateRangeTask?.IsCompleted ?? false)
                {
                    return;
                }

                //Set value must be stable
                TimeSpan preSleep = TimeSpan.FromMilliseconds(200);

                //Don't spam
                TimeSpan postSleep = TimeSpan.FromMilliseconds(200);

                _updateRangeTask = Task.Run(() =>
                {
                    Thread.Sleep(preSleep);

                    while (_resetRangeTask)
                    {
                        Debug.WriteLine("range task waiting ...");
                        _resetRangeTask = false;
                        Thread.Sleep(postSleep);
                    }

                    Debug.WriteLine($"set range to {_newZone.min}-{_newZone.max}");
                    SetStrokeZone(_newZone);
                });
            }
        }
Пример #2
0
        private void SetStrokeZone(HandySetStrokeZone stroke)
        {
            string url = GetQuery("setStrokeZone", stroke);

            SendGetRequest(url);
        }