本文整理汇总了C#中System.Threading.Timer.Change方法的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.Timer.Change方法的具体用法?C# System.Threading.Timer.Change怎么用?C# System.Threading.Timer.Change使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.Timer
的用法示例。
在下文中一共展示了System.Threading.Timer.Change方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExactIntervalTimer
public ExactIntervalTimer(int atHour, int atMin, int atSec)
{
tmr1 = new System.Timers.Timer();
tmr=new System.Threading.Timer(tmr_Elapse);
this.atHour= atHour;
this.atMin=atMin;
this.atSec=atSec;
System.DateTime now = System.DateTime.Now;
if (atHour != -1 && atMin != -1 && atSec != -1)
{
if (now < new System.DateTime(now.Year, now.Month, now.Day, atHour, atMin, atSec))
nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, atHour, atMin, atSec);
else
nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, atHour, atMin, atSec).AddHours(24);
}
else if (atHour == -1 && atMin != -1 && atSec != -1)
{
if (now < new System.DateTime(now.Year, now.Month, now.Day, now.Hour, atMin, atSec))
nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, now.Hour, atMin, atSec);
else
nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, now.Hour, atMin, atSec).AddHours(1);
}
else if (atHour == -1 && atMin == -1 && atSec != -1)
{
if (now < new System.DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, atSec))
nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, atSec);
else
nextInvokeTime = new System.DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, atSec).AddMinutes(1);
// tmr.Change(((TimeSpan)(nextInvokeTime - System.DateTime.Now)).Milliseconds, 1000 * 60 );
}
try
{
tmr.Change((int)((TimeSpan)(nextInvokeTime - now)).TotalMilliseconds, System.Threading.Timeout.Infinite);
}
catch (Exception ex)
{
tmr.Change(1, System.Threading.Timeout.Infinite);
}
}
示例2: BoringCommanderLogic
public BoringCommanderLogic(BoringCommander form)
{
_form = form;
_initBasicState();
System.Threading.Timer t = new System.Threading.Timer(_updConfig);
t.Change(50, 50);
}
示例3: Work
void Work()
{
LoadFile();
timer = new System.Threading.Timer(Output);
timer.Change(0, 1000);
}
示例4: button2_Click
//START Button
private void button2_Click(object sender, EventArgs e)
{
System.Threading.Timer timer = new System.Threading.Timer(urlSend);
timer.Change(0, 600000);
Console.WriteLine("Press Enter to exit");
Console.ReadLine();
}
示例5: RtkClient
public RtkClient(string ip,int port)
{
this.ip = ip;
this.port = port;
new System.Threading.Thread(ConnectionTask).Start();
tmr = new System.Threading.Timer(TimerCallBack);
tmr.Change(5000, 0);
}
示例6: R23PowerMeter
public R23PowerMeter(int erid, string ip, int port)
{
this.ip = ip;
this.port = port;
this.ERID = erid;
tmr = new System.Threading.Timer(TmrCallBack);
tmr.Change(0, 10 * 60 * 1000);
TmrCallBack(null);
}
示例7: Timer
public Timer()
{
_enabled = false;
_frequency = TimeSpan.FromSeconds(1.0 / 100);
_interrupt = false;
_timer = new ThreadTimer(o => _interrupt = true);
_timer.Change(_frequency, _frequency);
}
示例8: GameplayForm
public GameplayForm(UDPClientServerCommons.Client.ClientSide clientSide)
{
InitializeComponent();
System.Threading.TimerCallback tc = new System.Threading.TimerCallback(timerCallback);
gameLoopTimer = new System.Threading.Timer(tc);
gameLoopTimer.Change(1000, 1000);
network = clientSide;
//gameLoopTimer = new System.Threading.Timer(new System.Threading.TimerCallback(timerCallback), null, 0, 1000);
}
示例9: TickRoller
/// <summary>
/// コンストラクタ
/// </summary>
public TickRoller()
{
string tickRollingSpan = WebConfigurationManager.AppSettings["TickRollingSpan"];
TimeSpan span;
if (!TimeSpan.TryParse(tickRollingSpan, out span))
{
span = TimeSpan.FromSeconds(10);
}
HostingEnvironment.RegisterObject(this);
_timer = new System.Threading.Timer(OnTimerElapsed);
_timer.Change(TimeSpan.Zero, span);
}
示例10: Form1
public Form1()
{
InitializeComponent();
_hideAction = new Action(() => Visible = false);
_showAction = new Action(() =>
{
SetPosition();
Visible = true;
});
var checkCapsTimer = new Timer(delegate { CheckCaps(); });
checkCapsTimer.Change(0, 10);
}
示例11: ETAGReader
System.Threading.Timer tmr; //= new System.Threading.Timer();
#endregion Fields
#region Constructors
public ETAGReader(string ip, int cmdport )
{
this.IP = ip;
this.CmdPort = cmdport;
// this.EventPort = eventport;
init_tcp();
Console.WriteLine("Set operation mode to active");
SetOperationModeActive();
Console.WriteLine("Version:" + GetVersion());
EventPort = GetEventPort();
Console.WriteLine("Event port:" + EventPort);
Console.WriteLine("model:" + GetModel());
Console.WriteLine("Antenna detect count:"+GetAtennaDetectCount());
Console.WriteLine("Antenna port count:" + GetAtennaPortCount());
Console.WriteLine("Error Status:" + GetErrorStatus());
tmr = new System.Threading.Timer(new System.Threading.TimerCallback(TmrCallback));
tmr.Change(0, 10000);
}
示例12: ControllerBase
public ControllerBase(ControllerConfigBase config,PropertyBag property)
{
this.PropertyBag = property;
this.DeviceType = config.device_type;
this.ListenPort = config.listen_port;
this.ControllerID = config.controller_id;
this.BuildDate = config.build_date;
this.VersionNo = config.version_no;
tmrPeriodDataReport = new System.Threading.Timer(new System.Threading.TimerCallback(PeroidDataReportTask));
this.config = config;
CreateDevices(config);
tmrHwStatus = new System.Threading.Timer(new System.Threading.TimerCallback(TmrHwStausTask));
// tmrHwStatus.Change(0, 1000);
SetHWStatusTmr();
// tmrPeriodDataReport.Change(GetNextTransmitSeconds()*1000,this.PropertyBag.TransmitCycle*60* 1000);
SetTransmitCycleTmr();
StartListening(ListenPort);
OneMinTmr = new System.Threading.Timer(OneMinTask);
OneMinTmr.Change(GetNextMinDifferentSec()*1000, 60 * 1000);
this.protocol.Parse(System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "protocol.txt"), false);
this.PropertyBag.OnHWStatus_Changed += new EventHandler(PropertyBag_OnHWStatus_Changed);
}
示例13: Application_Launching
// Code to execute when the application is launching (eg, from Start)
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
if (timer == null)
{
timer = new System.Threading.Timer((_) =>
{
this.RootFrame.Dispatcher.BeginInvoke(() =>
{
if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() && !this.IsNetworkAvailable)
{
this.IsNetworkAvailable = false;
MessageBox.Show(TextosFront.frontMensajeConexionInternet);
}
else
{
this.IsNetworkAvailable = true;
}
});
});
timer.Change(0, 5000);
}
serviceRequest = new ServiceRequest2();
Santander.DataAccess.Services.InitializeServices();
Santander.DataAccess.Jsons.InitializeJsons();
Santander.View.Views.InitializeViews();
selectedEstatusTransferencia = null;
selectedServicio = null;
SelectedConsultaCuentasRegistradas = null;
}
示例14: init_tmr
static void init_tmr()
{
// tmr2min.Elapsed += new System.Timers.ElapsedEventHandler(tmr2min_Elapsed);
// tmr30Sec.Elapsed += new System.Timers.ElapsedEventHandler(tmr30Sec_Elapsed);
DateTime nextTime = DateTime.Now.AddMinutes(1).AddSeconds(-DateTime.Now.Second+30);
tmr1min = new System.Threading.Timer(tmr60Sec_Elapsed);
tmr1min.Change((int)((TimeSpan)(nextTime - DateTime.Now)).TotalMilliseconds, System.Threading.Timeout.Infinite);
tmr5min = new System.Threading.Timer(tmr5min_Elapsed);
nextTime = DateTime.Now.AddMinutes(-DateTime.Now.Minute % 5).AddSeconds(-DateTime.Now.Second+30).AddMinutes(5);
tmr5min.Change((int)((TimeSpan)(nextTime - DateTime.Now)).TotalMilliseconds, System.Threading.Timeout.Infinite);
tmr30min.Elapsed += new System.Timers.ElapsedEventHandler(tmr30min_Elapsed);
tmr1hour.Elapsed += new System.Timers.ElapsedEventHandler(tmr1hour_Elapsed);
//tmr30Sec_Elapsed(null, null);
//tmr2min_Elapsed(null, null);
// tmr30Sec.Start();
//tmr2min.Start();
tmr1hour.Start();
tmr30min.Start();
}
示例15: Application_Activated
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
if (timer == null)
{
timer = new System.Threading.Timer((_) =>
{
this.RootFrame.Dispatcher.BeginInvoke(() =>
{
if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() && !this.IsNetworkAvailable)
{
this.IsNetworkAvailable = false;
MessageBox.Show(TextosFront.frontMensajeConexionInternet);
}
else
{
this.IsNetworkAvailable = true;
}
});
});
timer.Change(0, 5000);
}
serviceRequest = new ServiceRequest2();
Santander.DataAccess.Services.InitializeServices();
Santander.DataAccess.Jsons.InitializeJsons();
Santander.View.Views.InitializeViews();
bool statusLoadCliente = false;
bool sesionInit = false;
IsolatedStorageSettings.ApplicationSettings.TryGetValue("Cuentas", out this.Cuentas);
IsolatedStorageSettings.ApplicationSettings.TryGetValue("Tarjetas", out this.Tarjetas);
IsolatedStorageSettings.ApplicationSettings.TryGetValue("TotalCuentas", out this.TotalCuentas);
IsolatedStorageSettings.ApplicationSettings.TryGetValue("FechaActual", out this.fechaActual);
IsolatedStorageSettings.ApplicationSettings.TryGetValue("EstatusToken", out this.EstatusToken);
IsolatedStorageSettings.ApplicationSettings.TryGetValue("EstatusSoftToken", out this.EstatusSoftToken);
IsolatedStorageSettings.ApplicationSettings.TryGetValue("ZonaToken", out TokenManager.ZONA);
IsolatedStorageSettings.ApplicationSettings.TryGetValue("LastOtp", out TokenManager.lastOtp);
if (IsolatedStorageSettings.ApplicationSettings.TryGetValue("SesionIniciada", out sesionInit))
this.SesionIniciada = sesionInit;
if (this.SesionIniciada)
{
if (PhoneApplicationService.Current.State.ContainsKey("loadClienteStatus"))
{
statusLoadCliente = (bool)PhoneApplicationService.Current.State["loadClienteStatus"];
if (statusLoadCliente)
{
clienteLSP = new ClienteLoadSaveP();
if (clienteLSP.loadClient())
{
System.Diagnostics.Debug.WriteLine("cliente cargado");
this.cliente.getFechaActual();
this.cliente.ClienteLoad = statusLoadCliente;
}
}
this.loadSaveCliente = true;
}
}
this.matrix = Validaciones.cargarCSVResToken();
}