Esempio n. 1
0
        public static void StartService()
        {
            try
            {
                BService     service      = new BService();
                JobProcessor jobProcessor = new JobProcessor();
                jobProcessor.ExceptionOccur += delegate(object sender, EventArgs <Exception> e)
                {
                    Log <BService> .Logger.Error("StartService", e.Value);
                };
                service.Initialize(jobProcessor);
                jobProcessor.Start();
                Register registerop = new Register(typeof(BService));
                registerop.OnComplete += delegate(Operation op)
                {
                    Log <BService> .Logger.DebugFormat("{0} registered on {1} : port {2}", registerop.Category, registerop.ID, registerop.Port);

                    service.ID     = registerop.ID;
                    service.Suffix = registerop.Suffix;
                    service.Start(registerop.Port);
                };
                registerop.OnFail += delegate(Operation op)
                {
                    Log <BService> .Logger.ErrorFormat("cannot find LocationService or register failed : {0}", registerop.Category);

                    service.Dispose();
                };
                jobProcessor.Enqueue(Job.Create <string, Register>(new Action <string, Register>(service.RequestOperation), typeof(UnifiedNetwork.LocationService.LookUp).FullName, registerop));
            }
            catch (Exception ex)
            {
                Log <BService> .Logger.Error("StartService", ex);
            }
        }
Esempio n. 2
0
 public Test()
 {
     Test.Execute(Test.locationArgs);
     AService.StartService();
     BService.StartService();
 }