Cancel() public method

public Cancel ( ) : void
return void
コード例 #1
0
        private void Timer_Tick(ThreadPoolTimer timer)
        {
            try
            {
                var devicesList = ftManager.GetDeviceList();
                Debug.WriteLine(devicesList.Count);

                if (devicesList.Count > 0)
                {
                    timer.Cancel();

                    var infoNode = devicesList[0];
                    IFTDevice ftDevice = ftManager.OpenByDeviceID(infoNode.DeviceId);

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                    ftDevice.SetBaudRateAsync(9600);
                    ftDevice.SetDataCharacteristicsAsync(WORD_LENGTH.BITS_8, STOP_BITS.BITS_1, PARITY.NONE);
                    ftDevice.SetFlowControlAsync(FLOW_CONTROL.NONE, 0x00, 0x00);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

                    device = new XBeeDevice(ftDevice);
                    ListenForData();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #2
0
 private void Timer_Tick(ThreadPoolTimer threadPoolTimer)
 {
     var tiltSensorValue = _gpioSensors[TiltSensorPin].Read();
     if (tiltSensorValue == GpioPinValue.High)
     {
         _halper.DishwasherEmptied();
     }
     threadPoolTimer.Cancel();
 }
コード例 #3
0
        private void Timer_Tick(ThreadPoolTimer timer)
        {
            timer.Cancel();

            list.Clear();

            var sw = new Stopwatch();
            sw.Start();

            var mercury = new MercuryAccess();
            var success = mercury.CallMPS().Result;
            sw.Stop();

            elapsedTime = (double)sw.ElapsedMilliseconds/(double)1000.0;            

            list.Add(string.Format("{0}    ElapsedTime: {1}", DateTime.Now, elapsedTime));

            totalTime += elapsedTime;

            list.Add(string.Format("{0}    TotalTime: {1}", DateTime.Now, totalTime));

            totalTransactions++;

            list.Add(string.Format("{0}    Total Transactions: {1}", DateTime.Now, totalTransactions));

            averageTimePerTransaction = (double)totalTime / (double)totalTransactions;

            list.Add(string.Format("{0}    Average Transaction Time: {1}", DateTime.Now, averageTimePerTransaction));

            totalToBlinkGreen = 10;
            totalToBlinkRed = 10;
            NextActionIsShowTransactionTiming = true;

            ShowTransactionSuccess(success);            
        }
 private async void Handler(ThreadPoolTimer timer)
 {
     _counter++;
     timer.Cancel();
     await _taskFactory.StartNew(() => SendX10Packet(_counter, 10, 8));
     ThreadPoolTimer.CreatePeriodicTimer(Handler, TimeSpan.FromSeconds(5));
 }
コード例 #5
0
        private void check_received_acks(ThreadPoolTimer timer)
        {
            if (_old_counter_all_acks != _counter_all_acks)
            {
                _counter_to_ack_error = 0;
                _old_counter_all_acks = _counter_all_acks;
            }
            else
            {
                _counter_to_ack_error++;
            }

            if (_counter_to_ack_error > 20)
            {
                _bluetooth_client.Dispose();
                timer.Cancel();

                _message = format_message(_stopwatch.Elapsed, "File Transfer", "NOK", "Timeout error when receiving acks.");
                this.callback.on_file_received(_message, this.results);
                this.main_view.text_to_logs(_message.Replace("\t", " "));
            }
        }
コード例 #6
0
        private async void PokeballUpdateLoop(ThreadPoolTimer timer)
        {
            if (UpdateLoopMutex.WaitOne(0))
            {
                DateTime curTime = DateTime.Now;

                // timeDelta is the seconds since last update
                float timeDelta = (curTime - prevTime).Milliseconds / 1000f;
                
                Vector3 gravity = new Vector3(0, 300f, 0);

                // Apply basic Kinematics
                ThrowItemPosition += (ThrowItemVelocity * timeDelta) + (.5f * gravity * timeDelta * timeDelta);
                ThrowItemVelocity += (gravity * timeDelta);

                /*
                Logger.Write("Position" + ThrowItemPosition.X + ", " + ThrowItemPosition.Y + ", " + ThrowItemPosition.Z);
                Logger.Write("Velocity" + ThrowItemVelocity.X + ", " + ThrowItemVelocity.Y + ", " + ThrowItemVelocity.Z);
                */

                prevTime = curTime;

                // Shotty attempt at converting from world space to screen space without a matrix
                var translateX = ThrowItemPosition.X * Math.Max(1.0f - (ThrowItemPosition.Z / 400.0f), 0.0f);
                var translateY = ThrowItemPosition.Y - (ThrowItemPosition.Z);
                var scaleX = Math.Max(1.0f - (ThrowItemPosition.Z / 200.0f), 0.0f);
                var scaleY = scaleX;
                
                var pokeballStopped = false;
                var pokemonHit = false;

                if (Vector3.DistanceSquared(PokemonPosition, ThrowItemPosition) < PokemonRadiusSq)
                {
                    // We hit the pokemon!
                    pokeballStopped = true;
                    pokemonHit = true;
                    timer.Cancel();
                    Logger.Write("Hit Pokemon! " + ThrowItemPosition.X + ", " + ThrowItemPosition.Y + ", " + ThrowItemPosition.Z);
                }
                else if (ThrowItemPosition.Y > 50)
                {
                    // We missed the pokemon...
                    timer.Cancel();
                    pokeballStopped = true;
                    Logger.Write("Missed Pokemon! " + ThrowItemPosition.X + ", " + ThrowItemPosition.Y + ", " + ThrowItemPosition.Z);
                    // TODO: We need to use up a pokeball on the missed throw
                }

                UpdateLoopMutex.ReleaseMutex();

                await PokeballTransform.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                {
                    PokeballTransform.TranslateX = PokeballCatchAnimationStartingTranslateX.Value = translateX;
                    PokeballTransform.TranslateY = PokeballCatchAnimationStartingTranslateY.Value = translateY;
                    PokeballTransform.ScaleX = PokeballCatchAnimationStartingScaleX.Value = scaleX;
                    PokeballTransform.ScaleY = PokeballCatchAnimationStartingScaleY.Value = scaleY;
                    if (pokeballStopped)
                    {
                        if (pokemonHit)
                        {                            
                            CatchSuccess.Begin();                            
                            ViewModel.UseSelectedCaptureItem.Execute(true);
                        }
                        else
                        {
                            // TODO: move the missed command if you want
                            ViewModel.UseSelectedCaptureItem.Execute(false);
                            PokeballTransform.TranslateX = InitItemX;
                            PokeballTransform.TranslateY = InitItemY;
                            PokeballTransform.ScaleX = 1;
                            PokeballTransform.ScaleY = 1;
                            LaunchPokeballButton.IsEnabled = true;
                        }
                    }
                });
            }
        }
コード例 #7
0
        private void ResetTimer(ThreadPoolTimer currentTimer, uint timerId, int durrationMs)
        {
            if (currentTimer != null)
            {
                currentTimer.Cancel();
            }

            _timer = ThreadPoolTimer.CreateTimer(
                (ThreadPoolTimer timer) =>
                {
                    Timer_Tick(timerId, timer);
                },
                TimeSpan.FromMilliseconds(durrationMs));
        }
コード例 #8
0
        private void ResetTimer(ThreadPoolTimer currentTimer)
        {
            if (currentTimer != null)
            {
                currentTimer.Cancel();
            }

            _timer = null;
        }