Inheritance: IDisposable
Exemple #1
0
        public static void Main(string[] args) {
            var server = new SocketServer(IPAddress.Parse(Ip), Port);
            server.Start();

            var input = string.Empty;
            while (input.ToLower() != "q") {
                Console.WriteLine("Enter 'Q' or 'q' to exit.");
                input = Console.ReadLine().ToLower();
            }
            server.Stop();
            server.Dispose();
        }
 private static void Main(string[] args)
 {
     var maxConcurrentJobs = GetMaxConcurrentJobs();
     var allTaskList = new BlockingCollection<Job>();
     var socketServer = new SocketServer(IPAddress.Loopback, 6666);
     var jobQueue = new JobQueue();
     var scheduler = new Scheduler(jobQueue);
     using (var queueProcessor = new QueueProcessor(maxConcurrentJobs, jobQueue))
     {
         var commandProcessor = new CommandProcessor(allTaskList, scheduler, jobQueue, queueProcessor);
         using (var dispatcher = new CommandDispatcherService(socketServer, commandProcessor))
         using (var display = new DisplayService(allTaskList, jobQueue))
         {
             Console.ReadLine();
         }
     }
 }
Exemple #3
0
        private void tspbtnStart_Click(object sender, EventArgs e)
        {
            // 按扭
            this.tsptxbServerIp.ReadOnly = true;
            this.tsptxbServerPort.ReadOnly = true;
            this.tspbtnStart.Enabled = false;

            try
            {
                // 建立伺服端
                Server = new SocketServer(this.tsptxbServerIp.Text, this.tsptxbServerPort.Text, this);
                // 運行伺服端
                Task.Factory.StartNew(() => Server.Start(), TaskCreationOptions.LongRunning);
            }
            catch (Exception ex)
            {
                ServerError.Error("啟動伺服器時發生錯誤!\n\rMessage: {0},\r\n StackTrace: {1}\r\n", ex.Message, ex.StackTrace);
            }
        }
Exemple #4
0
        public static void Main()
        {
            SocketServer socketServer = new SocketServer(port);

            socketServer.Run().Wait();
        }
Exemple #5
0
 public void Stop()
 {
     Logger.Log(this, "Stopped");
     SocketServer.Dispose();
     Active = false;
 }