• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Threading.Timer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



System.Threading.Timer类属于命名空间,在下文中一共展示了System.Threading.Timer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: StartHook

            public static void StartHook(PhysicalKeys[] listenFor)
            {
                if (listenFor == null || listenFor.Length == 0)
                {
                    throw new ArgumentException("listenFor; null or 0 length");
                }

                m_listenFor = listenFor.Select(enu => (int)enu).ToArray();

                if (!isRunninghook)
                {
                    isRunninghook = true;

                    hookThread = new System.Threading.Timer((callback) =>
                    {
                        while (true)
                        {
                            for (int i = 0; i < m_listenFor.Length; i++)
                            {
                                if (DllImportCaller.lib.GetAsyncKeyState7(m_listenFor[i]) != 0) //OPTIMIZE, SO FEW CALLS POSSIBLE; Phone.KeyboardHook.IsKeyDown(m_listenFor[i]))
                                {
                                    if (OnKeyDown != null)
                                    {
                                        OnKeyDown(null, (PhysicalKeys)m_listenFor[i]);
                                    }
                                }
                            }

                            System.Threading.Thread.Sleep(500);
                        }

                    }, null, 0, System.Threading.Timeout.Infinite);
                }
            }
开发者ID:ApexHAB,项目名称:apex-lumia,代码行数:34,代码来源:KeyboardHook.cs


示例2: BusinessGraphicsForm

        //static long nextTick = DateTime.Now.Ticks;

        public BusinessGraphicsForm(BusinessGraphicsSourceDesign sourceDesign, Window window)
        {
            InitializeComponent();
            if (window is ActiveWindow)
            {
                wnd = (ActiveWindow)window;
                BackColor = wnd.BorderColorFrienly;
            }
            sourceDesign.Wnd = wnd;
            sourceDesign.IsPlayerMode = true;
            _sourceCopy = SourceDesignClone(sourceDesign);
            this.sourceDesign = sourceDesign;
            this.sourceDesign.InitializeChart(true);

            Controls.Clear();
            this.sourceDesign.AddChartToContainer(this, wnd);

            FormClosing += BusinessGraphicsForm_FormClosing;

            if (sourceDesign.ODBCRefreshInterval > 0)
            {
                int time = sourceDesign.ODBCRefreshInterval*1000;
                if (((BusinessGraphicsResourceInfo) sourceDesign.ResourceDescriptor.ResourceInfo).ProviderType ==
                    ProviderTypeEnum.ODBC)
                    refreshTimer = new Timer(RefreshChart, "Timer", time, time);
            }
            //начал делать тут проверку, а она оказывается не нужна//
            //nextTick += time; 
        }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:31,代码来源:BusinessGraphicsForm.cs


示例3: NodeGroup

		internal NodeGroup(RelayNodeGroupDefinition groupDefinition, RelayNodeConfig nodeConfig, ForwardingConfig forwardingConfig)
		{   
			GroupDefinition = groupDefinition;
			Activated = groupDefinition.Activated;
			_clusterByRange = groupDefinition.UseIdRanges;
			_forwardingConfig = forwardingConfig;
			NodeSelectionHopWindowSize = groupDefinition.NodeSelectionHopWindowSize;
			RelayNodeClusterDefinition myClusterDefinition = NodeManager.Instance.GetMyNodeClusterDefinition();

			foreach (RelayNodeClusterDefinition clusterDefintion in groupDefinition.RelayNodeClusters)
			{
				NodeCluster nodeCluster = new NodeCluster(clusterDefintion, nodeConfig, this, forwardingConfig);
				if (clusterDefintion == myClusterDefinition)
				{
					MyCluster = nodeCluster;
				}
				Clusters.Add(nodeCluster);
			}

			_nodeReselectTimerCallback = new System.Threading.TimerCallback(NodeReselectTimer_Elapsed);
			if (_nodeReselectTimer == null)
			{
				_nodeReselectTimer = new System.Threading.Timer(_nodeReselectTimerCallback);
			}
			_nodeReselectTimer.Change(NodeReselectIntervalMilliseconds, NodeReselectIntervalMilliseconds);

			QueueTimerCallback = new System.Threading.TimerCallback(QueueTimer_Elapsed);
			if (QueueTimer == null)
			{
				QueueTimer = new System.Threading.Timer(QueueTimerCallback);
			}
			QueueTimer.Change(DequeueIntervalMilliseconds, DequeueIntervalMilliseconds);
		}
开发者ID:edwardt,项目名称:MySpace-Data-Relay,代码行数:33,代码来源:NodeGroup.cs


示例4: AutoClosingMessageBox

 public AutoClosingMessageBox(Form f, String text, String caption, Int32 timeout)
 {
     _caption = caption;
     _timeoutTimer = new System.Threading.Timer(OnTimerElapsed,
         null, timeout, System.Threading.Timeout.Infinite);
     MessageBoxEx.Show(f, text, caption);
 }
开发者ID:henryxrl,项目名称:SimpleEpub2,代码行数:7,代码来源:AutoClosingMessageBox.cs


示例5: FileWatcher

        public FileWatcher(string path, string[] filter)
        {
            if (filter == null || filter.Length == 0)
            {
                FileSystemWatcher mWather = new FileSystemWatcher(path);
                mWather.Changed += new FileSystemEventHandler(fileSystemWatcher_Changed);
                mWather.Deleted += new FileSystemEventHandler(fileSystemWatcher_Changed);
                mWather.Created += new FileSystemEventHandler(fileSystemWatcher_Changed);
                mWather.EnableRaisingEvents = true;
                mWather.IncludeSubdirectories = false;
                mWathers.Add(mWather);
            }
            else
            {
                foreach (string item in filter)
                {
                    FileSystemWatcher mWather = new FileSystemWatcher(path, item);
                    mWather.Changed += new FileSystemEventHandler(fileSystemWatcher_Changed);
                    mWather.Deleted += new FileSystemEventHandler(fileSystemWatcher_Changed);
                    mWather.Created += new FileSystemEventHandler(fileSystemWatcher_Changed);
                    mWather.EnableRaisingEvents = true;
                    mWather.IncludeSubdirectories = false;
                    mWathers.Add(mWather);
                }
            }
            mTimer = new System.Threading.Timer(OnDetect, null, 5000, 5000);

        }
开发者ID:hdxhan,项目名称:IKendeLib,代码行数:28,代码来源:FileWatcher.cs


示例6: Prompt

        public bool Prompt()
        {
            var bReturn = false;
            var bRunning = IsRunning(m_szProcessName);

            if (IsRunning(m_szProcessName))
            {
                m_form =
                    new ClosePromptForm(string.Format(
                        "Please close running instances of {0} before running {1} setup.", m_szDisplayName,
                        m_szProductName));
                m_mainWindowHanle = FindWindow(null, m_szProductName + " Setup");
                if (m_mainWindowHanle == IntPtr.Zero)
                {
                    m_mainWindowHanle = FindWindow("#32770", m_szProductName);
                }

                m_timer = new Timer(TimerElapsed, m_form, 200, 200);

                bReturn = ShowDialog();
            }
            else
            {
                bReturn = true;
            }
            return bReturn;
        }
开发者ID:exxeleron,项目名称:qXL,代码行数:27,代码来源:PromptCloseApplication.cs


示例7: InitApp

        /// <summary>
        /// Performs all the operations needed to init the plugin/App
        /// </summary>
        /// <param name="user">singleton instance of UserPlugin</param>
        /// <param name="rootPath">path where the config files can be found</param>
        /// <returns>true if the user is already logged in; false if still logged out</returns>
        public static bool InitApp(UserClient user, string rootPath, IPluginManager pluginManager)
        {
            if (user == null)
                return false;

            // initialize the config file
            Snip2Code.Utils.AppConfig.Current.Initialize(rootPath);
            log = LogManager.GetLogger("ClientUtils");
 
            // login the user
            bool res = user.RetrieveUserPreferences();
            bool loggedIn = false;
            if (res && ((!BaseWS.Username.IsNullOrWhiteSpaceOrEOF()) || (!BaseWS.IdentToken.IsNullOrWhiteSpaceOrEOF())))
            {
                LoginPoller poller = new LoginPoller(BaseWS.Username, BaseWS.Password, BaseWS.IdentToken, BaseWS.UseOneAll,
                                                        pluginManager);
                LoginTimer = new System.Threading.Timer(poller.RecallLogin, null, 0, AppConfig.Current.LoginRefreshTimeSec * 1000);
                loggedIn = true;
            }

            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                user.LoadSearchHistoryFromFile();
            }, null);

            //set the empty profile picture for search list results:
            PictureManager.SetEmptyProfilePic(rootPath);

            return loggedIn;
        }
开发者ID:modulexcite,项目名称:snip2codeNET,代码行数:36,代码来源:ClientUtils.cs


示例8: ObjectManager

        //private static ConcurrentDictionary<long, Level> m_vInMemoryPlayers { get; set; }

        public ObjectManager()
        {
            m_vTimerCanceled = false;
            m_vDatabase = new DatabaseManager();
            NpcLevels = new Dictionary<int, string>();
            DataTables = new DataTables();
            m_vAlliances = new Dictionary<long, Alliance>();

            if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
            {
                LoadFingerPrint();
            }

            using (StreamReader sr = new StreamReader(@"gamefiles/default/home.json"))
            {
                m_vHomeDefault = sr.ReadToEnd();
            }

            m_vAvatarSeed = m_vDatabase.GetMaxPlayerId() + 1;
            m_vAllianceSeed = m_vDatabase.GetMaxAllianceId() + 1;
            LoadGameFiles();
            LoadNpcLevels();

            System.Threading.TimerCallback TimerDelegate = new System.Threading.TimerCallback(Save);
            System.Threading.Timer TimerItem = new System.Threading.Timer(TimerDelegate, null, 60000, 60000);
            TimerReference = TimerItem;

            Console.WriteLine("Database Sync started");
            m_vRandomSeed = new Random();
        }
开发者ID:0trebor0,项目名称:clash-of-warriors-server,代码行数:32,代码来源:ObjectManager.cs


示例9: StartPeriodicTasks

 public static void StartPeriodicTasks(IDocumentStore documentStore, int dueMinutes = 1, int periodMinutes = 4)
 {
     if (timer == null)
     {
         bool working = false;
         timer = new System.Threading.Timer((state) =>
         {
             //Block is not necessary because it is called periodically
             if (!working)
             {
                 working = true;
                 try
                 {
                     using (var session = documentStore.OpenSession())
                     {
                         (new ExecuteScheduledTasks() { RavenSession = session }).Execute();
                     }
                 }
                 catch (Exception e)
                 {
                     log.ErrorException("Error on global.asax timer", e);
                 }
                 working = false;
             }
         },
         null,
         TimeSpan.FromMinutes(dueMinutes),
         TimeSpan.FromMinutes(periodMinutes));
     }
 }
开发者ID:sofipacifico,项目名称:CommonJobs,代码行数:30,代码来源:ExecuteScheduledTasks.cs


示例10: BoringCommanderLogic

 public BoringCommanderLogic(BoringCommander form)
 {
     _form = form;
     _initBasicState();
     System.Threading.Timer t = new System.Threading.Timer(_updConfig);
     t.Change(50, 50);
 }
开发者ID:podkolzzzin,项目名称:boringCommander,代码行数:7,代码来源:BoringCommanderLogic.cs


示例11: AntTracker

        //FiltroMediana filtroLat = new FiltroMediana(10);
        //FiltroMediana filtroLon = new FiltroMediana(10);
        //FiltroMediana filtroAlt = new FiltroMediana(10);


        public AntTracker()
        {
       
            planeStateUpdated = false;
            terminate = false;
            antenaTracker = new AntenaTracker();
            datosAvion = new AntTrackerDatosAvion();
            datosAvion.LoadDefaults();

            debug = new AntTrackerDebug();
            debug.LoadDefaults();

            if (antenaTracker.IsOpen())
            {
                timer = new System.Threading.Timer(TimerTask, this, 1000, 1000 /5);
            }
            else if (singleton.Idioma == 0)
            {
                MessageBox.Show("No se puede abrir dispositivo AntTracker");
            }
            else
            {
                MessageBox.Show("Cannot open AntTracker device");
            }
        }
开发者ID:rajeper,项目名称:ikarus-osd,代码行数:30,代码来源:AntTracker.cs


示例12: BtnBrowseImage_Click

 private void BtnBrowseImage_Click(object sender, RoutedEventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog
     {
         Multiselect = false, //Filter = "Jpeg Files (*.jpg)|*.jpg|All Files(*.*)|*.*",
         Filter = "JPEG Images (*.jpeg *.jpg)|*.jpeg;*.jpg|Png Images (*.png)|*.png",
     };
     if (ofd.ShowDialog() == true)
     {
         try
         {
             LoadingInfo.Visibility = System.Windows.Visibility.Visible;
             focusRectangle.Viewport.Visibility = System.Windows.Visibility.Collapsed;
             focusRectangle.LoadImageStream(ofd.File.OpenRead(), ZoomInOut);
             fileInfo = ofd.File;
             BtnUploadImage.IsEnabled = BtnAdvanceMode.IsEnabled = false;
             ZoomInOut.IsEnabled = true;
             System.Threading.Timer timer = new System.Threading.Timer(TimerCallback,
                  new LoadingState()
                  {
                      focusRectangle = focusRectangle,
                      LoadingInfo = LoadingInfo,
                      BtnUploadImage = BtnUploadImage,
                      BtnAdvanceMode = BtnAdvanceMode
                  } as object,
                  1000, 500);   
         }
         catch (Exception exception)
         {
             Utils.ShowMessageBox("文件无效:" + exception.Message);
             ZoomInOut.IsEnabled = false;
             BtnUploadImage.IsEnabled = BtnAdvanceMode.IsEnabled = false;
         }
     }
 }
开发者ID:wenysky,项目名称:dnt31-lite,代码行数:35,代码来源:ImageBrowser.xaml.cs


示例13: FFTDraw

 public FFTDraw()
 {
     // Insert initialization code here.
     this.data = new float[512];
     this.updater = new System.Threading.Timer(this.DoFFT);
     this.updater.Change(0, 50);
 }
开发者ID:madrang,项目名称:FmodSharp,代码行数:7,代码来源:FFTDraw.cs


示例14: UploadManager

		public UploadManager(MetainfoFile infofile, DownloadFile downloadFile)
		{
			this.infofile = infofile;
			this.downloadFile = downloadFile;

			this.chokeTimer = new System.Threading.Timer(new System.Threading.TimerCallback(OnChokeTimer), null, Config.ChokeInterval, Config.ChokeInterval);
		}
开发者ID:peteward44,项目名称:torrent.net,代码行数:7,代码来源:uploadmanager.cs


示例15: Main

        public Main()
        {
            this.InitializeComponent();

            this.playlistExtender = new ListViewExtender(this.playlist);

            // extend 2nd column
            var buttonAction = new ListViewButtonColumn(this.playlist.Columns.Count - 1);
            buttonAction.Click += this.PlaySingleAction;
            buttonAction.FixedWidth = true;

            this.playlistExtender.AddColumn(buttonAction);
            this.DragEnter += MainDragEnter;
            this.DragDrop += MainDragDrop;

            this.addDialog = new AddDialog();
            this.settingsDialog = new Settings();

            this.lblVersion.Text = string.Format("Version {0} [[email protected]]", Application.ProductVersion);

            this.settingSerializer = new DisplaySettingSerializer();
            this.playlistSerializer = new PlaylistSerializer();

            this.mouseTimer = new System.Threading.Timer(DisplayMousePosition);

            this.Disposed += Main_Disposed;
        }
开发者ID:feg-giessen,项目名称:videocommander,代码行数:27,代码来源:Main.cs


示例16: BuildSample

        public static void BuildSample(IAppBuilder app)
        {
            // add eventsource middleware
            app.EventSource(envKey);
            app.Run(context => {

                // get the event stream (not captured yet)
                var eventStream = context.Environment[envKey] as IEventStream;

                // create some timers to send mesages
                var timer = new System.Threading.Timer(_ => {
                    var ts = DateTime.UtcNow.ToString("O");
                    eventStream.WriteAsync("Timer1:" + ts + message + "\n");
                }, null, 1,  50);
                var timer2 = new System.Threading.Timer(_ => {
                    var ts = DateTime.UtcNow.ToString("O");
                    eventStream.WriteAsync("Timer 2:" + ts + "\n");
                }, null, 1,  25);

                // Capture the eventstream by calling Open and pass in the 
                // clean-up logic for when this client closes the stream
                var task =  eventStream.Open(() => {
                    Console.WriteLine("Closed");
                    timer.Dispose();
                    timer2.Dispose();
                });

                eventStream.WriteAsync("Started\n");
                return task;
            });
        }
开发者ID:Xamarui,项目名称:OwinUtils,代码行数:31,代码来源:EventSourceSample.cs


示例17: Program

        public Program()
        {
            bool isProcessing = false;
               this._stopwatch = new System.Diagnostics.Stopwatch();
               this._capture = new Capture();

               this.components = new System.ComponentModel.Container();
               this.contextMenu = new System.Windows.Forms.ContextMenu();
               this.menuItem = new System.Windows.Forms.MenuItem();
               this.contextMenu.MenuItems.AddRange(
                           new System.Windows.Forms.MenuItem[] { this.menuItem });
               this.menuItem.Index = 0;
               this.menuItem.Text = "E&xit";
               this.menuItem.Click += new System.EventHandler(
                    delegate(object sender, EventArgs e) {
                         Application.Exit();
                    });
               this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
               notifyIcon.Icon = new Icon("info.ico");
               notifyIcon.ContextMenu = this.contextMenu;
               notifyIcon.Text = "Shoulder Surfer Alert";
               notifyIcon.Visible = true;

               this._runner = new System.Threading.Timer(new System.Threading.TimerCallback(
                    delegate(object state) {
                         if (!(bool)state) {
                              state = true;
                              this.ProcessFaces();
                              state = false;
                         }
                    }), isProcessing, 0, 500);
        }
开发者ID:wendellinfinity,项目名称:ShoulderSurferAlert,代码行数:32,代码来源:Program.cs


示例18: Frm_SmartBrightness

 public Frm_SmartBrightness()
 {
     InitializeComponent();
     crystalButton_Cancel.BringToFront();
     _topmostTimer = new System.Threading.Timer(ThreadSetTopMostCallback);
     uC_BrightnessConfigExample.CloseFormHandler += uC_BrightnessConfigExample_CloseFormHandler;
 }
开发者ID:hardborn,项目名称:MonitorManager,代码行数:7,代码来源:Frm_SmartBrightness.cs


示例19: InitApp

		public void InitApp()
		{
			InitializeMainViewControllers();
			InitializeTabController();
			
			timer = new System.Threading.Timer(GetNotifications, null, 4000, 5 * 60 * 1000);
		}
开发者ID:21Off,项目名称:21Off,代码行数:7,代码来源:AppDelegateUIBuilder.cs


示例20: FormMain

        /// <summary>Initializes a new instance of the FormMain class.</summary>
        public FormMain(bool startLogging)
        {
            // This call is required by the designer
            InitializeComponent();

            // Initialize private variables
            p_CurrentIP = "-";
            p_CurrentStatus = StatusCode.None;
            p_ElapsedSeconds = 0;
            p_StartLogging = startLogging;
            p_StartupTime = DateTime.Now;
            p_TimerLog = null;

            // Initialize FormMain properties
            this.ClientSize = new Size(660, 480);
            this.Font = SystemFonts.MenuFont;

            // Initialize tray icon
            IconMain.ContextMenu = MenuMain;

            // Initialize Menu/ToolBar
            MenuShowSuccessful.Checked = Settings.Default.ShowSuccessful;
            MenuShowStatusChanges.Checked = Settings.Default.ShowStatusChanges;
            MenuShowErrors.Checked = Settings.Default.ShowErrors;
            ToolBarShowSuccessful.Pushed = MenuShowSuccessful.Checked;
            ToolBarShowStatusChanges.Pushed = MenuShowStatusChanges.Checked;
            ToolBarShowErrors.Pushed = MenuShowErrors.Checked;
        }
开发者ID:AdamWarnock,项目名称:Speed-Test-Loggger,代码行数:29,代码来源:FormMain.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Timers.Timer类代码示例发布时间:2022-05-24
下一篇:
C# Threading.Thread类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap