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


C# Threading.Timer类代码示例

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


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


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