本文整理汇总了C#中Timer类的典型用法代码示例。如果您正苦于以下问题:C# Timer类的具体用法?C# Timer怎么用?C# Timer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Timer类属于命名空间,在下文中一共展示了Timer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 1:
{
TimeSpan duration = reader.ReadTimeSpan();
m_Timer = new InternalTimer(this, duration);
m_Timer.Start();
m_End = DateTime.Now + duration;
break;
}
case 0:
{
TimeSpan duration = TimeSpan.FromSeconds(10.0);
m_Timer = new InternalTimer(this, duration);
m_Timer.Start();
m_End = DateTime.Now + duration;
break;
}
}
}
示例2: Main
private static void Main()
{
DefaultMediaDevice = new MMDeviceEnumerator().GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
DefaultMediaDevice.AudioEndpointVolume.OnVolumeNotification += new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification);
TrayIcon = new NotifyIcon();
TrayIcon.Icon = IconFromVolume();
TrayIcon.Text = ToolTipFromVolume();
TrayIcon.MouseClick += new MouseEventHandler(TrayIcon_MouseClick);
TrayIcon.MouseDoubleClick += new MouseEventHandler(TrayIcon_MouseDoubleClick);
TrayIcon.Visible = true;
TrayIcon.ContextMenu = new ContextMenu();
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("Open Volume Mixer", (o, e) => { Process.Start(SystemDir + "sndvol.exe"); }));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("-"));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("Playback devices", (o, e) => { Process.Start(SystemDir + "rundll32.exe", @"Shell32.dll,Control_RunDLL mmsys.cpl,,playback"); }));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("Recording devices", (o, e) => { Process.Start(SystemDir + "rundll32.exe", @"Shell32.dll,Control_RunDLL mmsys.cpl,,recording"); }));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("Sounds", (o, e) => { Process.Start(SystemDir + "rundll32.exe", @"Shell32.dll,Control_RunDLL mmsys.cpl,,sounds"); }));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("-"));
TrayIcon.ContextMenu.MenuItems.Add(new MenuItem("Volume control options", (o, e) => { Process.Start(SystemDir + "sndvol.exe", "-p"); }));
SingleClickWindow = new Timer();
SingleClickWindow.Interval = SystemInformation.DoubleClickTime;
SingleClickWindow.Tick += (o, e) =>
{
SingleClickWindow.Stop();
StartVolControl();
};
Application.Run();
}
示例3: RectangleTransparent
public RectangleTransparent()
{
clearPen = new Pen(Color.FromArgb(1, 0, 0, 0));
borderDotPen = new Pen(Color.Black, 1);
borderDotPen2 = new Pen(Color.White, 1);
borderDotPen2.DashPattern = new float[] { 5, 5 };
penTimer = Stopwatch.StartNew();
ScreenRectangle = CaptureHelpers.GetScreenBounds();
surface = new Bitmap(ScreenRectangle.Width, ScreenRectangle.Height);
gSurface = Graphics.FromImage(surface);
gSurface.InterpolationMode = InterpolationMode.NearestNeighbor;
gSurface.SmoothingMode = SmoothingMode.HighSpeed;
gSurface.CompositingMode = CompositingMode.SourceCopy;
gSurface.CompositingQuality = CompositingQuality.HighSpeed;
gSurface.Clear(Color.FromArgb(1, 0, 0, 0));
StartPosition = FormStartPosition.Manual;
Bounds = ScreenRectangle;
Text = "ShareX - " + Resources.RectangleTransparent_RectangleTransparent_Rectangle_capture_transparent;
Shown += RectangleLight_Shown;
KeyUp += RectangleLight_KeyUp;
MouseDown += RectangleLight_MouseDown;
MouseUp += RectangleLight_MouseUp;
using (MemoryStream cursorStream = new MemoryStream(Resources.Crosshair))
{
Cursor = new Cursor(cursorStream);
}
timer = new Timer { Interval = 10 };
timer.Tick += timer_Tick;
timer.Start();
}
示例4: Form1
public Form1()
{
InitializeComponent();
ControlledProcess = new Process();
Temperature = new TemperatureWorker(1000); //refresh time = 1000ms
TimerInt = new Timer();
TimerInt.Interval = 1000;
TimerInt.Tick += new EventHandler(timer_tick);
TimerInt.Start();
statusStrip1.Text = "statusStrip1";
statusStrip1.Items.Add("Core 1:");
statusStrip1.Items[0].AutoSize = false;
statusStrip1.Items[0].Size = new Size(statusStrip1.Width / 5, 1);
statusStrip1.Items.Add("Core 2:");
statusStrip1.Items[1].AutoSize = false;
statusStrip1.Items[1].Size = new Size(statusStrip1.Width / 5, 1);
statusStrip1.Items.Add("Core 3:");
statusStrip1.Items[2].AutoSize = false;
statusStrip1.Items[2].Size = new Size(statusStrip1.Width / 5, 1);
statusStrip1.Items.Add("Core 4:");
statusStrip1.Items[3].AutoSize = false;
statusStrip1.Items[3].Size = new Size(statusStrip1.Width / 5, 1);
}
示例5: frmSplash
public frmSplash()
{
InitializeComponent();
label1.Parent = pictureBox1;
label1.BackColor = Color.Transparent;
label2.Parent = pictureBox1;
label2.BackColor = Color.Transparent;
label3.Parent = pictureBox1;
label3.BackColor = Color.Transparent;
label4.Parent = pictureBox1;
label4.BackColor = Color.Transparent;
label5.Parent = pictureBox1;
label5.BackColor = Color.Transparent;
version.Parent = pictureBox1;
version.BackColor = Color.Transparent;
lblbuilddate.Parent = pictureBox1;
lblbuilddate.BackColor = Color.Transparent;
version.Text = "Version " + Application.ProductVersion;
lblbuilddate.Text = "Build Date: " + Utility.RetrieveLinkerTimestamp().ToString();
LoadPluginSplash();
m_timer = new Timer();
m_timer.Interval = 20;
m_timer.Tick += new EventHandler(m_timer_Tick);
m_timer.Start();
Opacity = 0.0;
}
示例6: StartTimer
/// <summary>
/// Starts the timer.
/// </summary>
public void StartTimer()
{
timer = new Timer();
timer.Interval = 250;
timer.Tick += new EventHandler(Timer_Tick);
timer.Start();
}
示例7: OnInitialise
protected override void OnInitialise()
{
base.OnInitialise();
_tickTimer = _timeTrigger;
r_singleShot = _singleShot;
_hasTicked = false;
}
示例8: MapViewControl
public MapViewControl(frmMain Owner)
{
_Owner = Owner;
InitializeComponent();
ListSelect = new ContextMenuStrip();
ListSelect.ItemClicked += ListSelect_Click;
ListSelect.Closed += ListSelect_Close;
UndoMessageTimer = new Timer();
UndoMessageTimer.Tick += RemoveUndoMessage;
OpenGLControl = Program.OpenGL1;
pnlDraw.Controls.Add(OpenGLControl);
GLInitializeDelayTimer = new Timer();
GLInitializeDelayTimer.Interval = 50;
GLInitializeDelayTimer.Tick += GLInitialize;
GLInitializeDelayTimer.Enabled = true;
tmrDraw = new Timer();
tmrDraw.Tick += tmrDraw_Tick;
tmrDraw.Interval = 1;
tmrDrawDelay = new Timer();
tmrDrawDelay.Tick += tmrDrawDelay_Tick;
tmrDrawDelay.Interval = 30;
UndoMessageTimer.Interval = 4000;
}
示例9: ChocHelper
public ChocHelper(MediaBrowser.Library.Item Item)
{
this.OverviewTimer = new Timer();
this.CurrentItem = Item;
this.setupHelper();
Instance = this;
}
示例10: OnDoubleClick
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
return;
}
if ( Core.AOS && (from.Paralyzed || from.Frozen || (from.Spell != null && from.Spell.IsCasting)) )
{
//to prevent exploiting for pvp
from.SendLocalizedMessage( 1075857 ); // You can not use that while paralyzed.
return;
}
if ( m_Timer == null )
{
m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 1 ), TimeSpan.FromSeconds( 1 ), new TimerCallback( OnFirebombTimerTick ) );
m_LitBy = from;
from.SendLocalizedMessage( 1060581 ); //You light the firebomb! Throw it now!
}
else
from.SendLocalizedMessage( 1060582 ); //You've already lit it! Better throw it now!
from.BeginTarget( 12, true, TargetFlags.None, new TargetCallback( OnFirebombTarget ) );
}
示例11: RotatingColor
public RotatingColor()
{
timer = new Timer();
timer.Tick += new EventHandler(this.Tick);
timer.Interval = 50;
hslcolor = new HSLColor(0.0, 240.0, 120.0);
}
示例12: RouletteTable
public RouletteTable(int maxChipsOnTable, RandomNumberGenerator generator, Timer timer, WalletService walletService)
{
this.maxChipsOnTable = maxChipsOnTable;
this.rng = generator;
this.timer = timer;
this.walletService = walletService;
}
示例13: TreeStump
public TreeStump(int itemID)
: base()
{
this.AddComponent(new AddonComponent(itemID), 0, 0, 0);
this.m_Timer = Timer.DelayCall(TimeSpan.FromDays(1), TimeSpan.FromDays(1), new TimerCallback(GiveLogs));
}
示例14: MainForm_Load
/// <summary>
/// フォームのロード時
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainForm_Load(object sender, EventArgs e)
{
m_timer = new Timer();
m_timer.Tick += this.timerTickHandler;
m_timer.Interval = this.calcInterval();
m_timer.Start();
}
示例15: QuickFillScreen2_Opened
void QuickFillScreen2_Opened(System.Object sender, System.EventArgs e)
{
tmrPressMonitor = new Timer();
tmrPressMonitor.Interval = 500;
tmrPressMonitor.Enabled = true;
tmrPressMonitor.Tick += MONITOR_TICK;
}