title: Getting user input from other threads
body: <p>I am running a console application with two threads, the main thread and another thread. The other thread is executed at a certain time (i have used Timer). In both threads i expect user input for example Main thread => give me your name Child thread => give me your age. All i want to do is when the child thread is executed to not mess with the user input from main thread, so after finishing from child thread (getting the user input) to get the user input from main thread. When i execute this code and i am ready to enter name in main thread, the child thread executed and prompts to enter age. When i enter something this input is saved to the name in main thread.
  This is my code</p>
  
  <pre><code>using System;
  using System.Threading;
  
  static class ThreadSafe
  {
    private static Timer timer;
    static readonly object locker = new object();
  
    static void Main()
    {
        new Thread(() =&gt; SetUpTimer(
           new TimeSpan(20, 07,
               50))).Start();
        Console.WriteLine("give me your name");
        string a = Console.ReadLine();
        Console.WriteLine(a);
    }
  
    static void SetUpTimer(TimeSpan alertTime)
    {
        DateTime current = DateTime.Now;
        TimeSpan timeToGo = alertTime - 
         current.TimeOfDay;
        if (timeToGo &gt;= TimeSpan.Zero)
        {
            timer = new Timer(x =&gt; { askNow(2); }, 
            null, timeToGo,
            Timeout.InfiniteTimeSpan);
        }
    }
  
    static void askNow(int id)
    {
        lock (locker)
        {
  
            Console.WriteLine("give me your age");
            string b = Console.ReadLine();
            Console.WriteLine(b + "b");
        }
      }
   }
  </code></pre>