コード例 #1
0
        private static void StartRandom(AddSubscriber addSub)
        {
            Random       rand         = new Random(Guid.NewGuid().GetHashCode());
            SwitchDevice switchDevice = null;

            while (true)
            {
                addSub.ChangeSwitch(rand, switchDevice);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            AddSubscriber addSub = new AddSubscriber();

            addSub.AddSwitchesInDict();

            InitializeSubscribeService(addSub);

            Console.WriteLine("Press ENTER to start randomize");
            Console.ReadKey(true);
            Console.WriteLine("You have started randomizing");
            StartRandom(addSub);

            Console.ReadLine();
        }
コード例 #3
0
        private static void InitializeSubscribeService(AddSubscriber addSub)
        {
            try
            {
                string      address = "net.tcp://localhost:4000/IAddSubscriber";
                ServiceHost host    = new ServiceHost(addSub);

                host.AddServiceEndpoint(typeof(IAddSubscriber), new NetTcpBinding(), new Uri(address));
                host.Open();

                Console.WriteLine("Server open on address: {0}", address);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }