当前位置: 首页>>代码示例>>C#>>正文


C# ThreadPoolTimer.Cancel方法代码示例

本文整理汇总了C#中Windows.System.Threading.ThreadPoolTimer.Cancel方法的典型用法代码示例。如果您正苦于以下问题:C# ThreadPoolTimer.Cancel方法的具体用法?C# ThreadPoolTimer.Cancel怎么用?C# ThreadPoolTimer.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.System.Threading.ThreadPoolTimer的用法示例。


在下文中一共展示了ThreadPoolTimer.Cancel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Timer_Tick

        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;
            }
        }
开发者ID:jklemmack,项目名称:IoTIrrigationController,代码行数:29,代码来源:MainPage.xaml.cs

示例2: Timer_Tick

 private void Timer_Tick(ThreadPoolTimer threadPoolTimer)
 {
     var tiltSensorValue = _gpioSensors[TiltSensorPin].Read();
     if (tiltSensorValue == GpioPinValue.High)
     {
         _halper.DishwasherEmptied();
     }
     threadPoolTimer.Cancel();
 }
开发者ID:ChrisMancini,项目名称:DishwasherMonitor,代码行数:9,代码来源:GpioMonitor.cs

示例3: Timer_Tick

        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);            
        }
开发者ID:VantivLabs,项目名称:RaspberryPi.CSharp,代码行数:35,代码来源:MainPage.xaml.cs

示例4: Handler

 private async void Handler(ThreadPoolTimer timer)
 {
     _counter++;
     timer.Cancel();
     await _taskFactory.StartNew(() => SendX10Packet(_counter, 10, 8));
     ThreadPoolTimer.CreatePeriodicTimer(Handler, TimeSpan.FromSeconds(5));
 }
开发者ID:RodneyWimberly,项目名称:Windows.Devices.Radios.nRF24L01P,代码行数:7,代码来源:ReadAndWriteToRoomExtender.cs

示例5: check_received_acks

        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", " "));
            }
        }
开发者ID:StabilityofWT,项目名称:Stability-Monitor,代码行数:22,代码来源:Bluetooth_agent.cs

示例6: PokeballUpdateLoop

        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;
                        }
                    }
                });
            }
        }
开发者ID:Zampeta1,项目名称:PoGo-UWP,代码行数:77,代码来源:CapturePokemonPage.xaml.cs

示例7: ResetTimer

        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));
        }
开发者ID:FaithZeroWigs,项目名称:VoiceRover,代码行数:14,代码来源:MainPage.xaml.cs


注:本文中的Windows.System.Threading.ThreadPoolTimer.Cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。