本文整理汇总了C#中System.Timers.Timer.Start方法的典型用法代码示例。如果您正苦于以下问题:C# System.Timers.Timer.Start方法的具体用法?C# System.Timers.Timer.Start怎么用?C# System.Timers.Timer.Start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Timers.Timer
的用法示例。
在下文中一共展示了System.Timers.Timer.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Application_Start
void Application_Start(object sender, EventArgs e)
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
var cancellationToken = new CancellationToken();
var scheduledTaskDeamon = new Task(token =>
{
var taskList = new IPeriodicTask[]
{
new SendEmailPeriodicTask(),
new CheckDatabasePeriodicTask()
};
foreach (var scheduledTask in taskList)
{
var timer = new System.Timers.Timer(scheduledTask.RunInterval);
timer.Elapsed += (o, args) =>
{
scheduledTask.TaskStart();
timer.Start();
};
timer.AutoReset = false;
timer.Start();
}
}, cancellationToken);
scheduledTaskDeamon.Start();
}
示例2: TestLeapPlayerLoop
public void TestLeapPlayerLoop()
{
for (int i = 0; i < 3; i++)
{
var testOver = new ManualResetEventSlim();
var timeoutTimer = new Timer(10000);
var player = new LeapPlayer(@"frames\rotate_1.frames");
player.LoopOutput = true;
var bytesExpected = player.FileSizeInBytes * 3;
Action<Frame> frameListener = frame =>
{
timeoutTimer.Stop();
timeoutTimer.Start();
if (player.TotalBytesRead >= bytesExpected)
{
testOver.Set();
}
};
player.FrameReady += frameListener;
timeoutTimer.Elapsed += (sender, args) => testOver.Set();
player.StartConnection();
timeoutTimer.Start();
testOver.Wait();
player.StopConnection();
Assert.IsTrue(player.TotalBytesRead >= bytesExpected);
}
}
示例3: TakePictureInternal
protected override void TakePictureInternal(Action<byte[]> callback)
{
List<byte[]> pictures = new List<byte[]>();
var timer = new System.Timers.Timer(3000);
int count = 0;
timer.Elapsed += (sender, args) =>
{
++count;
if (count > 3)
{
timer.Stop();
byte[] result = ProcessImages(pictures);
callback(result);
return;
}
timer.Stop();
ImageProcessor.DoTakePicture(stream =>
{
pictures.Add(stream);
timer.Start();
});
};
timer.Start();
}
示例4: Init
public void Init()
{
var timer = new System.Timers.Timer();
timer.Interval = 100;
timer.Elapsed += async (_, __) =>
{
timer.Stop();
App.Current.Dispatcher.BeginInvoke(new Action(async () =>
{
this.Measurement = await this.sensor.MeasureAsync();
timer.Start();
}));
};
timer.Start();
}
示例5: OnStart
protected override void OnStart(string[] args) {
base.OnStart(args);
switch (ReceiverKind) {
case SupportedReceiver.RoyalTek:
_reader = new RoyalTekReader(Port, 0);
((RoyalTekReader)_reader).Frequency = Frequency;
break;
default:
Log.Warn("{0} recieved is unsupported.", ReceiverKind);
break;
}
if (_reader != null) {
_reader.TmcTransmissionArrived += onDataArrived;
var tm = new System.Timers.Timer {
Interval = 30000,
AutoReset = true
};
tm.Elapsed += new System.Timers.ElapsedEventHandler((o, a) => _sendTrafficState());
tm.Start();
var lookup = new TmcLookup(_reader);
lookup.StartLookupForTmc();
} else {
throw new NotSupportedException("Unable to initialize serial TMC reader");
}
}
示例6: 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();
}
示例7: ClassWithFinalizer
public ClassWithFinalizer()
{
_sillyTimer = new System.Timers.Timer(100);
_sillyTimer.Elapsed +=
(a, b) => Console.WriteLine("Still Alive");
_sillyTimer.Start();
}
示例8: OnStart
protected override void OnStart(string[] args)
{
ATFEnvironment.Log.logger.Info(string.Format("Test Case Manager Windows Service is starting..."));
timer = new System.Timers.Timer(1000 * 60 * 60 * 6);//6 hours
timer.Elapsed += MonitorTestCases;
timer.Start();
}
示例9: OnStartUp
public override void OnStartUp()
{
_timer = new Timer(1000);
//_timer.Elapsed += Elapsed;
_timer.Start();
Elapsed(null, null);
}
示例10: OutputTCBase
public OutputTCBase(Protocol protocol, string devicename, string ip, int port, int deviceid, byte[] hw_status, bool isconnected )
: base(protocol, devicename, ip, port, deviceid, hw_status, isconnected)
{
tmrCheckOutput = new System.Timers.Timer(outputCompareMin*1000 * 60);
tmrCheckOutput.Elapsed += new System.Timers.ElapsedEventHandler(tmrCheckOutput_Elapsed);
tmrCheckOutput.Start();
}
示例11: button1_Click
private void button1_Click(object sender, EventArgs e)
{
tim = new System.Timers.Timer(25000);
tim.Elapsed += new System.Timers.ElapsedEventHandler(CheckPageAgain);
tim.Start();
CheckPageAgain(null, null);
}
示例12: Screensaver
public Screensaver()
{
App.splashWindow.StatusUpdate("Screensaver wird initialisiert");
InitializeComponent();
System.Timers.Timer timer = new System.Timers.Timer();
timer.Elapsed += timer_Tick;
timer.Interval = 2000;
timer.Start();
d.Add(0, "VVK");
d.Add(1, "Games");
d.Add(2, "MVV");
d.Add(3, "Schwarzes Brett");
d.Add(4, "News");
d.Add(5, "Raumplan");
DoubleAnimation OpacityAnim = new DoubleAnimation(.2, 1, new Duration(TimeSpan.FromSeconds(1)), FillBehavior.Stop);
OpacityAnim.AutoReverse = true;
OpacityAnim.RepeatBehavior = RepeatBehavior.Forever;
startLabel.BeginAnimation(Label.OpacityProperty, OpacityAnim);
DoubleAnimation OpacityAnim2 = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(.5)), FillBehavior.HoldEnd);
OpacityAnim2.Completed+=new EventHandler(OpacityAnim2_Completed2);
mainWindow.BeginAnimation(Label.OpacityProperty, OpacityAnim2);
App.splashWindow.StatusUpdate("Screensaver ist bereit");
}
示例13: GameCoordinator
public GameCoordinator(uint appID, SteamClient steamClient, CallbackManager callbackManager)
{
// Map gc messages to our callback functions
GCMessageMap = new Dictionary<uint, Action<IPacketGCMsg>>
{
{ (uint)EGCBaseClientMsg.k_EMsgGCClientWelcome, OnClientWelcome },
{ (uint)EGCItemMsg.k_EMsgGCUpdateItemSchema, OnItemSchemaUpdate },
{ (uint)EGCBaseMsg.k_EMsgGCSystemMessage, OnSystemMessage },
{ (uint)EGCBaseClientMsg.k_EMsgGCClientConnectionStatus, OnClientConnectionStatus },
{ (uint)4008 /* TF2's k_EMsgGCClientGoodbye */, OnClientConnectionStatus }
};
this.AppID = appID;
this.SteamClient = steamClient;
this.SteamGameCoordinator = SteamClient.GetHandler<SteamGameCoordinator>();
this.Name = string.Format("GC {0}", appID);
// Make sure Steam knows we're playing the game
Timer = new System.Timers.Timer();
Timer.Elapsed += OnTimerPlayGame;
Timer.Interval = TimeSpan.FromMinutes(5).TotalMilliseconds;
Timer.Start();
Timer = new System.Timers.Timer();
Timer.Elapsed += OnTimer;
callbackManager.Register(new Callback<SteamGameCoordinator.MessageCallback>(OnGameCoordinatorMessage));
}
示例14: GetIntAsync
public static Task<int> GetIntAsync(CancellationToken token = default(CancellationToken))
{
var tcs = new TaskCompletionSource<int>();
if (token.IsCancellationRequested)
{
tcs.SetCanceled();
return tcs.Task;
}
var timer = new System.Timers.Timer(3000);
timer.AutoReset = false;
timer.Elapsed += (s, e) =>
{
tcs.TrySetResult(10);
timer.Dispose();
};
if (token.CanBeCanceled)
{
token.Register(() => {
tcs.TrySetCanceled();
timer.Dispose();
});
}
timer.Start();
return tcs.Task;
}
示例15: YADataDBURLQueue
public YADataDBURLQueue(string dbConnectionString, int mode = 0)
{
Console.WriteLine("Создаем очередь");
tick += Tick;
work = false;
jobs_made = 0;
got_jobs = new Queue<DataDBURLJob>(0);
photo_aps = new Queue<DirtyApartments>(0);
disposed = false;
//обновляем ссылку на подключение к базе для всяких асинхронных передач данных в духе ошибок
ddbs = new DataDBAsynchService(dbConnectionString);
ddbs.WriteErrorMessage(dbConnectionString, 0, "", "start");
//получаем задания на парсинг
jobs = new DataDBURLJobs(ddbs, mode, false);
//jobs.SetJobToStartOrStop(true);
t_fill = new System.Timers.Timer();
t_fill.Elapsed += new System.Timers.ElapsedEventHandler(fill_timer);
t_fill.Interval = 30000;
t_restart = new System.Timers.Timer();
t_restart.Elapsed += new System.Timers.ElapsedEventHandler(restart_timer);
//рестартить раз в 12 часов
t_restart.Interval = 12 * 60 * 60 * 1000;
this.mode = mode;
pq = new PhotoQueue(ddbs);
arw = new AsyncRunWork();
ap = new apartments();
work = true;
t_fill.Start();
t_restart.Start();
Console.WriteLine("Создали очередь");
}