How to use timer in C#?
<p>I want my function to be executed every 2 seconds to check if there is any new user so that I could make a new log for them. This is in console application so i used Thread. But my console shut down after it run the function once. I am expecting the timer to run as long as I am running the console and my createLog function will be executed every 2 seconds. I am relatively new to C# so maybe my concept of timer is completely wrong. Please help...</p>

<pre><code>namespace ConsoleApplication1
{
    class Program
    {
        public static Hashtable clientsList = new Hashtable();


        static void Main(string[] args)
        {
            Timer t = new Timer(createLog, null, 0, 2000);


            IPAddress ip = IPAddress.Parse("127.0.0.1");
            TcpListener serverSocket = new TcpListener(ip, 9888);
            TcpClient clientSocket = default(TcpClient);
            int counter = 0;

            serverSocket.Start();
            .... //this main is monitoring the network....
           console.read();
        }



 private static void createLog(object state)
        {
         //this function checks the database and if there is new user it will create a new text file for he/she. 

        }
  }
</code></pre>
