Esempio n. 1
0
        static void Main(string[] args)
        {
            bool             active     = true;
            ThreadController controller = new ThreadController();

            while (active)
            {
                var    input = Console.ReadLine();
                string command;
                string parameter;
                if (input.Contains(" "))
                {
                    command   = input.Substring(0, input.IndexOf(" ")).Trim();
                    parameter = input.Substring(input.IndexOf(" "), input.Length - 1).Trim();
                }
                else
                {
                    command   = input;
                    parameter = "";
                }

                Console.WriteLine("COMMAND----------> " + input);

                if (command.Equals("Exit"))
                {
                    controller.exit();
                    active = false;
                }
                else if (command.Equals("List-Threads"))
                {
                    controller.listThreads();
                }
            }
        }
 public CommandConsumer(ThreadController controller)
 {
     this.controller = controller;
     config          = new ConsumerConfig
     {
         BootstrapServers     = server,
         GroupId              = Guid.NewGuid().ToString(),
         EnableAutoCommit     = true,
         StatisticsIntervalMs = 5000,
         SessionTimeoutMs     = 6000,
         AutoOffsetReset      = AutoOffsetReset.Latest,
         EnablePartitionEof   = true
     };
     source      = new CancellationTokenSource();
     canceltoken = source.Token;
 }
        /**
         * The main function for <DatabaseApplication>, holds the console input loop
         */
        static void Main(string[] args)
        {
            //bool: active
            //maintains the console input loop
            bool active = true;

            //obj: controller
            //The object that maintains and controlls the <DatabaseApplication> threads
            ThreadController controller = new ThreadController();

            while (active)
            {
                //strings: Input
                //
                //input - the input from the console
                //command - the portion of the input that determines which instruction to carry out
                //parameter - the part of a command that may be passed into a function as a parameter
                var    input = Console.ReadLine();
                string command;
                string parameter;

                if (input.Contains(" "))
                {
                    command   = input.Substring(0, input.IndexOf(" ")).Trim();
                    parameter = input.Substring(input.IndexOf(" "), input.Length - 1).Trim();
                }
                else
                {
                    command   = input;
                    parameter = "";
                }

                Console.WriteLine("COMMAND----------> " + input);

                if (command.Equals("Exit"))
                {
                    controller.exit();
                    active = false;
                }
                else if (command.Equals("List-Threads"))
                {
                    controller.listThreads();
                }
            }
        }