I am making a simple OS using cosmos. I am a beginner in c#. Run() method in cosmos's default code loops until I quit VMware. However, once I fix little bit, my program exits automatically. I don't understand why. I am trying to make it loop. Cosmo's default code before I fix:
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
}
protected override void Run()
{
Console.Write("Input: ");
var input = Console.ReadLine();
Console.Write("Text typed: ");
Console.WriteLine(input);
}
}
Below is my new Run() method. Everything else remains the same.
protected override void Run() {
Console.WriteLine("Input:");
String input = Console.ReadLine();
if (input.StartsWith("echo"))
{
var index = input.IndexOf("echo");
var initial = input.Substring(0, index);
var final = input.Substring(index + "echo".Length);
var echoInput = initial + final;
Console.WriteLine(echoInput);
}
}