本文整理汇总了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();
}
}
示例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();
}
示例3: MqttDataLayer
public MqttDataLayer(string clientId, string broker)
{
ClientId = clientId;
Broker = broker;
FakeDataTimer = new System.Timers.Timer(1500) {Enabled = false};
FakeDataTimer.Elapsed += FakeDataTimer_Elapsed;
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例9: ClassWithFinalizer
public ClassWithFinalizer()
{
_sillyTimer = new System.Timers.Timer(100);
_sillyTimer.Elapsed +=
(a, b) => Console.WriteLine("Still Alive");
_sillyTimer.Start();
}
示例10: OnStartUp
public override void OnStartUp()
{
_timer = new Timer(1000);
//_timer.Elapsed += Elapsed;
_timer.Start();
Elapsed(null, null);
}
示例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;
}
示例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");
}
示例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);
}
示例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);
}
示例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();
};
}