コード例 #1
0
        private void Work()
        {
            var listener = new CommandListener();

            while (!_stopBot)
            {
                try
                {
                    var task = listener.Listen(IPAddress.Any, TCP_PORT, 1000, true);
                    task.Wait();
                    if (task.Result.HasValue)
                    {
                        handleCommands(task.Result.Value);
                    }
                    else if (task.IsFaulted)
                    {
                        throw task.Exception;
                    }
                }
                catch (Exception ex) {
                    handleCommands(new KeyValuePair <string, string>("error", ex.ToString()));
                }
            }
        }