static void Main(string[] args) { var messageFromESB = new MessageFromESB(); MyServiceHost.StartService(); Console.WriteLine("MsgListener started."); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); MyServiceHost.StopService(); }
/*Jak wyżej, ale behavior dodany jako atrybut*/ internal void InitService22() { MyServiceHost host; try { /*Przekazanie precedury eventu z użyciem behavior dodany jako Atrybut, za pośrednictwem customowego Servicehost*/ host = new MyServiceHost(typeof(MyService22)); host.Info = Info11; host.Open(); Info("Service22 online."); } catch (Exception ex) { host = null; Info(string.Format("There is an issue with MyService22: '" + ex.Message + "'")); } }