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


C# Timers.Timer类代码示例

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


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

示例1: Process

        internal void Process()
        {
            dbHelper helper = new dbHelper();
            helper.UpdateMissedData();
            FillSettings();
            if (settings != null)
            {
                double timerInterval = 10;
                double.TryParse(settings["EmailSendInterval"], out timerInterval);
                int.TryParse(settings["ThreadCount"], out thread_count);

                if (timerInterval == 0)
                    timerInterval = 0.1;
                collection = new List<mailDetails>();

                emailerTimer = new System.Timers.Timer();
                emailerTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetMail);

                emailerTimer.Interval = 60000 * timerInterval;
                emailerTimer.Enabled = true;
                emailerTimer.AutoReset = true;
                emailerTimer.Start();

            }
        }
开发者ID:weragoda88,项目名称:bulkemailer,代码行数:25,代码来源:emailerService.cs

示例2: TestClient

        /// <summary>
        /// 
        /// </summary>
        public TestClient(ClientManager manager)
        {
            ClientManager = manager;

            updateTimer = new System.Timers.Timer(500);
            updateTimer.Elapsed += new System.Timers.ElapsedEventHandler(updateTimer_Elapsed);

            RegisterAllCommands(Assembly.GetExecutingAssembly());

            Settings.LOG_LEVEL = Helpers.LogLevel.Debug;
            Settings.LOG_RESENDS = false;
            Settings.STORE_LAND_PATCHES = true;
            Settings.ALWAYS_DECODE_OBJECTS = true;
            Settings.ALWAYS_REQUEST_OBJECTS = true;
            Settings.SEND_AGENT_UPDATES = true;
            Settings.USE_ASSET_CACHE = true;

            Network.RegisterCallback(PacketType.AgentDataUpdate, new NetworkManager.PacketCallback(AgentDataUpdateHandler));
            Network.OnLogin += new NetworkManager.LoginCallback(LoginHandler);
            Self.IM += Self_IM;
            Groups.GroupMembersReply += GroupMembersHandler;
            Inventory.OnObjectOffered += new InventoryManager.ObjectOfferedCallback(Inventory_OnInventoryObjectReceived);

            Network.RegisterCallback(PacketType.AvatarAppearance, new NetworkManager.PacketCallback(AvatarAppearanceHandler));
            Network.RegisterCallback(PacketType.AlertMessage, new NetworkManager.PacketCallback(AlertMessageHandler));

            VoiceManager = new VoiceManager(this);

            updateTimer.Start();
        }
开发者ID:RavenB,项目名称:gridsearch,代码行数:33,代码来源:TestClient.cs

示例3: MqttDataLayer

 public MqttDataLayer(string clientId, string broker)
 {
     ClientId = clientId;
     Broker = broker;
     FakeDataTimer = new System.Timers.Timer(1500) {Enabled = false};
     FakeDataTimer.Elapsed += FakeDataTimer_Elapsed;
 }
开发者ID:tchavdar,项目名称:Sensors-Dashboard,代码行数:7,代码来源:MQTT+Data+Layer.cs

示例4: OnStart

 protected override void OnStart(string[] args)
 {
     System.Timers.Timer timer = new System.Timers.Timer();
     timer.Interval = 60000; // 60 seconds
     timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer);
     timer.Start();
 }
开发者ID:dgeller-OUHSC,项目名称:winTTSService,代码行数:7,代码来源:TTSWinService.cs

示例5: Initialize

        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
                throw new ArgumentNullException("config");

            if (String.IsNullOrEmpty(name))
                name = "RiakSessionStateStore";

            base.Initialize(name, config);

            ApplicationName = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;

            Configuration cfg = WebConfigurationManager.OpenWebConfiguration(ApplicationName);
            _config = (SessionStateSection)cfg.GetSection("system.web/sessionState");

            var container = UnityBootstrapper.Bootstrap();
            _client = container.Resolve<IRiakClient>();

            var riakSessionConfiguration = container.Resolve<RiakSessionStateConfiguration>();
            int expiredSessionDeletionInterval = riakSessionConfiguration.TimeoutInMilliseconds;

            _expiredSessionDeletionTimer = new System.Timers.Timer(expiredSessionDeletionInterval);
            _expiredSessionDeletionTimer.Elapsed += ExpiredSessionDeletionTimerElapsed;
            _expiredSessionDeletionTimer.Enabled = true;
            _expiredSessionDeletionTimer.AutoReset = true;
        }
开发者ID:peschkaj,项目名称:CorrugatedIron.Samples,代码行数:26,代码来源:RiakSessionStateStore.cs

示例6: LongPollingAsync

        //LongPolling Action 1 - 处理客户端发起的请求
        public void LongPollingAsync()
        {
            var state = Request["state"];
            //计时器,5秒种触发一次Elapsed事件
            var timer = new System.Timers.Timer(1000);
            //告诉ASP.NET接下来将进行一个异步操作
            AsyncManager.OutstandingOperations.Increment();
            //订阅计时器的Elapsed事件
            timer.Elapsed += (sender, e) =>
            {
                //保存将要传递给LongPollingCompleted的参数
                AsyncManager.Parameters["model"] = new LoginLogModel();
                if (state != null)
                {
                    var log = _loginLogService.GetLoginLog(state);
                    if (log != null && log.IsDeleted == false)
                    {
                        //保存将要传递给LongPollingCompleted的参数
                        AsyncManager.Parameters["model"] = new LoginLogModel
                        {
                            Id = log.Id,
                            CreateTime = log.CreateTime,
                            State = log.State
                        };
                    }

                }
                //告诉ASP.NET异步操作已完成,进行LongPollingCompleted方法的调用
                AsyncManager.OutstandingOperations.Decrement();
            };
            //启动计时器
            timer.Start();
        }
开发者ID:iamike,项目名称:Mango-Cards,代码行数:34,代码来源:CometController.cs

示例7: TestClient

        /// <summary>
        /// 
        /// </summary>
        public TestClient(ClientManager manager)
        {
			ClientManager = manager;

            updateTimer = new System.Timers.Timer(500);
            updateTimer.Elapsed += new System.Timers.ElapsedEventHandler(updateTimer_Elapsed);

            RegisterAllCommands(Assembly.GetExecutingAssembly());

            Settings.DEBUG = true;
            Settings.LOG_RESENDS = false;
            Settings.STORE_LAND_PATCHES = true;
            Settings.ALWAYS_DECODE_OBJECTS = true;
            Settings.ALWAYS_REQUEST_OBJECTS = true;
            Settings.SEND_AGENT_UPDATES = true;

            Network.RegisterCallback(PacketType.AgentDataUpdate, new NetworkManager.PacketCallback(AgentDataUpdateHandler));

            Self.OnInstantMessage += new AgentManager.InstantMessageCallback(Self_OnInstantMessage);
            Groups.OnGroupMembers += new GroupManager.GroupMembersCallback(GroupMembersHandler);
            Inventory.OnObjectOffered += new InventoryManager.ObjectOfferedCallback(Inventory_OnInventoryObjectReceived);

            Network.RegisterCallback(PacketType.AvatarAppearance, new NetworkManager.PacketCallback(AvatarAppearanceHandler));
            Network.RegisterCallback(PacketType.AlertMessage, new NetworkManager.PacketCallback(AlertMessageHandler));
            
            updateTimer.Start();
        }
开发者ID:RavenB,项目名称:gridsearch,代码行数:30,代码来源:TestClient.cs

示例8: Main

        static void Main(string[] args)
        {
            TimeSpan TsStart = new TimeSpan(DateTime.Now.Ticks);
            String[] CmdArgs= System.Environment.GetCommandLineArgs();
            if (CmdArgs.Length > 1)
            {
                //参数0是它本身的路径
                String FileName = CmdArgs[1].ToString();
                String Dir = CmdArgs[2].ToString();
                String Url = CmdArgs[3].ToString();
                SnapShot sp = new SnapShot();
                sp.FileName = FileName;// "test.jpg";
                sp.Dir = Dir; //@"D:\web\7.03\eweb_lifetour";
                sp.Url = Url; //@"http://lifetour20.travelindex.com.tw/eWeb/GO/V_GO_Detail.asp?MGRUP_CD=0000&GRUP_CD=0000141015A&SUB_CD=GO&JOIN_TP=1";
                sp.Save();

            }

            System.Timers.Timer tmr = new System.Timers.Timer(20000);
            tmr.Elapsed += delegate
            {
                Environment.Exit(0);
            };
            tmr.Start();
            Console.ReadKey();
        }
开发者ID:CowellJackli,项目名称:AutoRunSnapShot,代码行数:26,代码来源:Program.cs

示例9: ClassWithFinalizer

 public ClassWithFinalizer()
 {
     _sillyTimer = new System.Timers.Timer(100);
     _sillyTimer.Elapsed +=
         (a, b) => Console.WriteLine("Still Alive");
     _sillyTimer.Start();
 }
开发者ID:RoykoSerhiy,项目名称:visualStudio_projects,代码行数:7,代码来源:Program.cs

示例10: OnStartUp

 public override void OnStartUp()
 {
     _timer = new Timer(1000);
     //_timer.Elapsed += Elapsed;
     _timer.Start();
     Elapsed(null, null);
 }
开发者ID:hepa,项目名称:symo,代码行数:7,代码来源:MonitoringServiceHost.cs

示例11: RaptorDBServer

        public RaptorDBServer(int port, string DataPath)
        {
            _path = Directory.GetCurrentDirectory();
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            _server = new NetworkServer();

            if (_S == "/")// unix system
                _datapath = DataPath.Replace("\\", "/");
            else
                _datapath = DataPath;

            if (_datapath.EndsWith(_S) == false)
                _datapath += _S;

            _raptor = RaptorDB.Open(DataPath);
            register = _raptor.GetType().GetMethod("RegisterView", BindingFlags.Instance | BindingFlags.Public);
            save = _raptor.GetType().GetMethod("Save", BindingFlags.Instance | BindingFlags.Public);
            Initialize();
            _server.Start(port, processpayload);

            // add timer to cleanup connected clients
            _concleanuptimer = new System.Timers.Timer(30 * 1000);
            _concleanuptimer.AutoReset = true;
            _concleanuptimer.Enabled = true;
            _concleanuptimer.Elapsed += _concleanuptimer_Elapsed;
        }
开发者ID:leinsister,项目名称:RaptorDB-Document,代码行数:26,代码来源:RaptorDBServer.cs

示例12: Main

        static void Main(string[] args)
        {
            ObjectBase.Container = MEFLoader.Init();

            System.Console.WriteLine("Starting up services");
            System.Console.WriteLine("");

            SM.ServiceHost hostStyleManger = new SM.ServiceHost(typeof(StyleManager));

            SM.ServiceHost hostProductManger = new SM.ServiceHost(typeof(ProductManager));

            /* More services to call  */
            StartService(hostStyleManger, "StyleManger Host");
            StartService(hostProductManger, "ProductManager Host");

            System.Timers.Timer timer = new System.Timers.Timer(10000);
            timer.Elapsed += OnTimerElapsed;
            timer.Start();

            System.Console.WriteLine("eCommerce Monitor has started.");

            System.Console.WriteLine("");
            System.Console.WriteLine("Press [Enter] to exit.");
            System.Console.ReadLine();

            timer.Stop();
            System.Console.WriteLine("eCommerce Monitor stopped.");

            StopService(hostStyleManger, "AccountManager Host");
            StopService(hostProductManger, "AccountManager Host");
        }
开发者ID:oscarlagatta,项目名称:HN-eCommerce,代码行数:31,代码来源:Program.cs

示例13: AutoCompleteTextBox

        public AutoCompleteTextBox()
        {
            controls = new VisualCollection(this);
            InitializeComponent();

            searchThreshold = 2;        // default threshold to 2 char

            // set up the key press timer
            keypressTimer = new System.Timers.Timer();
            keypressTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);

            // set up the text box and the combo box
            comboBox = new ComboBox();
            comboBox.IsSynchronizedWithCurrentItem = true;
            comboBox.IsTabStop = false;
            comboBox.SelectionChanged += new SelectionChangedEventHandler(comboBox_SelectionChanged);

            textBox = new TextBox();
            textBox.TextChanged += new TextChangedEventHandler(textBox_TextChanged);
            textBox.VerticalContentAlignment = VerticalAlignment.Center;

            controls.Add(comboBox);
            controls.Add(textBox);

        }
开发者ID:TrinityCore-Manager,项目名称:TrinityCore-Manager-v3,代码行数:25,代码来源:AutoCompleteTextBox.xaml.cs

示例14: Sessions

 public Sessions(TimeSpan timeout)
 {
     this.sessions = Hashtable.Synchronized(new Hashtable(32));
     this.timeout = timeout;
     this.timer = new System.Timers.Timer(timeout.TotalMilliseconds/2d);
     this.timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
 }
开发者ID:coolsula,项目名称:vidplaycorder,代码行数:7,代码来源:Sessions.cs

示例15: DisplayInfoOrError

        private void DisplayInfoOrError(string message, Int32 msTime, bool isError = false)
        {
            tbErrorOrInfo.Text = message;
            tbErrorOrInfo.Visibility = System.Windows.Visibility.Visible;

            if(isError)
            {
                tbErrorOrInfo.Foreground = Brushes.Red;
            }

            System.Timers.Timer timer = new System.Timers.Timer(msTime);

            timer.Start();

            timer.Elapsed += (sender, args) =>
            {
                Dispatcher.BeginInvoke(new System.Threading.ThreadStart(delegate
                {                
                    tbErrorOrInfo.Text = string.Empty;
                    tbErrorOrInfo.Visibility = System.Windows.Visibility.Collapsed;

                    if (isError)
                    {
                        tbErrorOrInfo.Foreground = Brushes.White;
                    }

                }), System.Windows.Threading.DispatcherPriority.Input);

                timer.Dispose();
            };            
        }
开发者ID:aramlaka,项目名称:ArbitrarySteam,代码行数:31,代码来源:MainWindow.xaml.cs


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