本文整理汇总了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;
}
}
示例2: Timer_Tick
private void Timer_Tick(ThreadPoolTimer threadPoolTimer)
{
var tiltSensorValue = _gpioSensors[TiltSensorPin].Read();
if (tiltSensorValue == GpioPinValue.High)
{
_halper.DishwasherEmptied();
}
threadPoolTimer.Cancel();
}
示例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);
}
示例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", " "));
}
}
示例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;
}
}
});
}
}
示例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));
}