Timer

Published on November 2016 | Categories: Documents | Downloads: 93 | Comments: 0 | Views: 472
of 2
Download PDF   Embed   Report

Comments

Content

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;

namespace OPC_project
{
class Program
{
static void Main(string[] args)
{
device dv1 = new device();
dv1.a = 2;
ConsoleKeyInfo key;
do
{
key = Console.ReadKey();
dv1.Run();
if (key.Key == ConsoleKey.A)
{
Console.WriteLine("iloveyou");
}
} while (key.Key != ConsoleKey.E);

}
public class device

{
Timer timer = null;
public int a ;
public int i;
public void Run()
{
timer = new Timer(300);
timer.AutoReset = true;
timer.Elapsed += new ElapsedEventHandler(UpdateTag);
timer.Start();
}
public void Stop()
{
if (timer != null)
timer.Dispose();
}
void UpdateTag(object obj, ElapsedEventArgs e)
{
a++;
i++;
Console.WriteLine(this.a.ToString());
}

}
}
}

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close