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


C# Timer类代码示例

本文整理汇总了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;
                    }
            }
        }
开发者ID:evildude807,项目名称:kaltar,代码行数:32,代码来源:NaturalFire.cs

示例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();
        }
开发者ID:factormystic,项目名称:SndVolPlus,代码行数:31,代码来源:Program.cs

示例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();
        }
开发者ID:KamilKZ,项目名称:ShareX,代码行数:35,代码来源:RectangleTransparent.cs

示例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);
        }
开发者ID:MohiuddinM,项目名称:TemperatureMonitor,代码行数:27,代码来源:Form1.cs

示例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;
        }
开发者ID:tojoevan,项目名称:BGC-CW,代码行数:30,代码来源:frmSplash.cs

示例6: StartTimer

 /// <summary>
 /// Starts the timer.
 /// </summary>
 public void StartTimer()
 {
     timer = new Timer();
     timer.Interval = 250;
     timer.Tick += new EventHandler(Timer_Tick);
     timer.Start();
 }
开发者ID:tea,项目名称:MOSA-Project,代码行数:10,代码来源:DisplayForm.cs

示例7: OnInitialise

 protected override void OnInitialise()
 {
     base.OnInitialise();
     _tickTimer = _timeTrigger;
     r_singleShot = _singleShot;
     _hasTicked = false;
 }
开发者ID:Barabicus,项目名称:ATOMFIACHRA,代码行数:7,代码来源:ObjectTransitionStandard.cs

示例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;
        }
开发者ID:Zabanya,项目名称:SharpFlame,代码行数:30,代码来源:MapViewControl.cs

示例9: ChocHelper

 public ChocHelper(MediaBrowser.Library.Item Item)
 {
     this.OverviewTimer = new Timer();
     this.CurrentItem = Item;
     this.setupHelper();
     Instance = this;
 }
开发者ID:softworkz,项目名称:MediaBrowser.Themes.Chocolate,代码行数:7,代码来源:ChocHelper.cs

示例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 ) );
		}
开发者ID:PepeBiondi,项目名称:runsa,代码行数:26,代码来源:Firebomb.cs

示例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);
 }
开发者ID:colin-harms,项目名称:FTDI-LED-Controller,代码行数:7,代码来源:ColorGenerator.cs

示例12: RouletteTable

 public RouletteTable(int maxChipsOnTable, RandomNumberGenerator generator, Timer timer, WalletService walletService)
 {
     this.maxChipsOnTable = maxChipsOnTable;
     this.rng = generator;
     this.timer = timer;
     this.walletService = walletService;
 }
开发者ID:8pointers,项目名称:tdd-exercises-csharp,代码行数:7,代码来源:RouletteTable.cs

示例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));
        }
开发者ID:FreeReign,项目名称:forkuo,代码行数:7,代码来源:TreeStump.cs

示例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();
 }
开发者ID:kurose,项目名称:BreakAlert,代码行数:12,代码来源:MainForm.cs

示例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;
 }
开发者ID:xukangmin,项目名称:Graftel_LRM_1402,代码行数:7,代码来源:QuickFillScreen2.Script.cs


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