Hi, I'm new to this forum and would like to ask a question relating to C#. I am trying to make my custom OS, and shutting it down, but I am encountering a problem. Here is what I have so far:

using System;
using Cosmos.Compiler.Builder;

namespace CosmosBoot1
{
    class Program
    {
        #region Cosmos Builder logic
        // Most users wont touch this. This will call the Cosmos Build tool
        [STAThread]
        static void Main(string[] args)
        {
            BuildUI.Run();
        }
        #endregion

        // Main entry point of the kernel
        public static void Init()
        {
            var xBoot = new Cosmos.Sys.Boot();
            xBoot.Execute();
            Console.WriteLine("XCube V0.01");
            Console.WriteLine("Type help for help");
            while (true)
            {
                string command = Console.ReadLine();
                switch (command)
                {
                    case "shutdown":
                        {
                            goto shutdown;
                            break;
                        }

                    case "help":
                        {
                            Console.WriteLine("shutdown---Shuts down XCube");
                            Console.WriteLine("manual---Displays XCube manual");
                            Console.WriteLine("help---Displays help");
                            Console.WriteLine("reboot---Reboots XCube");
                            break;
                        }

                    case "manual":
                        {
                            Console.WriteLine("Note: In Virtual Machines, the shutdown command simply hangs the machine, and does not close the window.");
                            break;
                        }


                    case "reboot":
                        {
                            Cosmos.Sys.Deboot.Reboot();
                            break;
                        }
                    default:
                        {
                            Console.WriteLine("No such command");
                            command = null;
                            break;
                        }


                }
            }
        }
    }
}

When I type in "shutdown", nothing happens and I can continue using other commands. When I type in "reboot" however, the input method freezes and I can no longer input any command, but my Virtual Machine does not reboot and instead shows a blinking cursor where I left off. I think this would be in the right forum, I'm not sure. Anyone HELP!!! Thanks in advance.

Hi requimrar, welcome here!
Line 31 of your code: Don't go to a label, call your ShutDown method here. A goto is something that is rarely needed in modern programming.

Thanks for your help, but here is where the problem comes in. It compiles perfectly when I do it, but when I type in "shutdown" it does not do anything. Similarly, when I type in "reboot", the cursor blinks rapidly and I cannot type in any commands, so in other words it hangs. Could you help me out there? Thanks.

PS. It is developed in Cosmos.

Show the code where Line 31 leads to.

well line 31 leads to a label that is at the end of the function Init() , which is supposed to end this. anyways I dumpd the idea so problem solved.

You should do it old Mac OS Style. You should just do:

Console.WriteLine("The system can now be powered down safely.");
Cosmos.Sys.Deboot.Shutdown();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.