Hello
I have two functions 'This' and 'Another'
If I type one of the functions in cmd it will invoke the typed function
For example; if I type 'this' it starts the functions 'this()'
But the problem is, I like that my program constantly listens to input
When the program is busy with on of the functions He waits untill the invoked function ends.
If I start the function 'this()' , I can not type my other function
'Another()' when he's still busy with the first. How I can solve this?
using System;
using System.Threading;
namespace CommandoTest
{
class CommandTest
{
static void Main(string[] args)
{
CommandTest c = new CommandTest();
string Command = Console.ReadLine();
while (Command != "stop")
{
switch (Command)
{
case "this":
c.This(50);
break;
case "another":
c.Another(50);
break;
default:
Console.WriteLine("Wrong input!");
break;
}
Command = Console.ReadLine();
}
Console.Read();
}
private void This(int var)
{
while (var >= 0)
{
var -= 5;
Thread.Sleep(100);
Console.WriteLine("You've typed 'this'");
}
}
public void Another(int var)
{
while (var <= 110)
{
var += 5;
Thread.Sleep(100);
Console.WriteLine("You've typed 'another'");
}
}
}
}