本文整理汇总了C#中NSTimer.Invalidate方法的典型用法代码示例。如果您正苦于以下问题:C# NSTimer.Invalidate方法的具体用法?C# NSTimer.Invalidate怎么用?C# NSTimer.Invalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSTimer
的用法示例。
在下文中一共展示了NSTimer.Invalidate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OneSecondTimer
void OneSecondTimer(NSTimer timer)
{
timerCount++;
var userInfoString = timer.UserInfo.ToString();
Console.WriteLine (String.Format("One Second Timer (Number {0}) With Timer Passed In fired with User Info '{1}'", timerCount, userInfoString));
// Invalidate the timer after 5 calls.
if(timerCount == 5)
{
timer.Invalidate();
timer = null;
}
}
示例2: AdvancedHudActionForRow
protected void AdvancedHudActionForRow(int row)
{
switch (row) {
case 0:
hud.SetCaption("This HUD will auto-hide in 2 seconds.");
hud.BlockTouches = true;
hud.Show();
hud.HideAfter(2.0);
break;
case 1:
hud.SetCaption("This HUD will update in 2 seconds.");
hud.BlockTouches = true;
hud.SetActivity(true);
hud.Show();
NSTimer.CreateScheduledTimer(2.0, () => { UpdatedHud(); });
break;
case 2:
{
float progress = 0.08f;
//NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:.02 target:self selector:@selector(tick:) userInfo:nil repeats:YES];
//[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
NSTimer timer = new NSTimer();
timer = NSTimer.CreateRepeatingScheduledTimer(0.02, () => {
progress += 0.01f;
hud.SetProgress(progress);
if (progress >= 1) {
progress = 0;
timer.Invalidate();
hud.Hide();
NSTimer.CreateScheduledTimer(0.2, () => { ResetProgress(); });
}
});
hud.SetCaption("Performing operation...");
hud.SetProgress(0.08f);
hud.BlockTouches = true;
hud.Show();
break;
}
case 3:
{
string[] captions = new [] { "Display #1", "Display #2", "Display #3" };
// Would love to just use UIImage but breaks when using a "null" image.
NSArray images = NSArray.FromObjects("", "", UIImage.FromBundle("19-check"));
NSNumber[] positions = new NSNumber[] { new NSNumber(2), new NSNumber(1), new NSNumber(2) };
NSNumber[] flags = new NSNumber[] { new NSNumber(false), new NSNumber(true), new NSNumber(false) };
hud.AddToQueue(captions, images, positions, flags);
hud.StartQueue();
NSTimer.CreateScheduledTimer(2.0, () => { ShowNextDisplayInQueue(); });
break;
}
}
}
示例3: AdvancedHudActionForRow
protected void AdvancedHudActionForRow(int row)
{
switch (row) {
case 0:
hud.SetCaption("This HUD will auto-hide in 2 seconds.");
hud.BlockTouches = true;
hud.Show();
hud.HideAfter(2.0);
break;
case 1:
hud.SetCaption("This HUD will update in 2 seconds.");
hud.BlockTouches = true;
hud.SetActivity(true);
hud.Show();
NSTimer.CreateScheduledTimer(2.0, () => { UpdatedHud(); });
break;
case 2:
{
float progress = 0.08f;
//NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:.02 target:self selector:@selector(tick:) userInfo:nil repeats:YES];
//[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
NSTimer timer = new NSTimer();
timer = NSTimer.CreateRepeatingScheduledTimer(0.02, () => {
progress += 0.01f;
hud.SetProgress(progress);
if (progress >= 1) {
progress = 0;
timer.Invalidate();
hud.Hide();
NSTimer.CreateScheduledTimer(0.2, () => { ResetProgress(); });
}
});
hud.SetCaption("Performing operation...");
hud.SetProgress(0.08f);
hud.BlockTouches = true;
hud.Show();
break;
}
case 3:
{
var item1 = new ATMHudQueueItem { Caption = "Display #1", AccessoryPosition = ATMHudAccessoryPosition.ATMHudAccessoryPositionBottom };
var item2 = new ATMHudQueueItem { Caption = "Display #2", AccessoryPosition = ATMHudAccessoryPosition.ATMHudAccessoryPositionRight, ShowActivity = true };
var item3 = new ATMHudQueueItem { Caption = "Display #3", Image = UIImage.FromBundle("19-check"), AccessoryPosition = ATMHudAccessoryPosition.ATMHudAccessoryPositionBottom };
hud.AddToQueue(new ATMHudQueueItem[] { item1, item2, item3 });
hud.StartQueue();
NSTimer.CreateScheduledTimer(2.0, () => { ShowNextDisplayInQueue(); });
break;
}
}
}