public void ServiceControllerTest() { Log.Debug("Main Thread started"); var sc = new ServiceController(); sc.Start(); Log.Debug("Main Thread go to sleep"); Thread.Sleep(16000); Log.Debug("Main thread is awake"); Log.Debug("Pause ServiceController"); sc.Pause(); Log.Debug("Main Thread go to sleep"); Thread.Sleep(8000); Log.Debug("Main thread is awake"); Log.Debug("Restart ServiceController"); sc.Play(); Log.Debug("Main Thread go to sleep"); Thread.Sleep(16000); Log.Debug("Main thread is awake"); Log.Debug("Stop ServiceController"); sc.Stop(); Log.Debug("ServiceLocator terminated"); }
static void Main() { if (!SingleInstance.Start()) { SingleInstance.ShowFirstInstance(); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { // TODO Remember to add Service.Close() call at application exit XmlConfigurator.Configure(); //ILog log = LogManager.GetLogger(this.GetType()); Type type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType; ILog log = LogManager.GetLogger(type); WherelessViewModel viewModel = WherelessViewModel.GetInstance(); ServiceController service = new ServiceController() { RadioOffCallback = viewModel.UpdateRadioOff, UpdateCurrentLocationCallback = viewModel.UpdateCurrentLocation }; viewModel.WherelessService = service; service.Start(); ////TEST-CODE //Thread.Sleep(5000); //viewModel.RegisterLocation("Casa Mare"); //viewModel.AddActivityToLocation(viewModel.CurrentLocation, "OpenBrowser", "firefox", "www.polito.it", "ExeFile"); //Thread.Sleep(5000); //viewModel.ForceUnknown(); //Thread.Sleep(5000); //viewModel.ForceLocation("Casa Mare"); //Thread.Sleep(5000); // Now move in another unknown location log.Info("whereless started..."); var applicationContext = new CustomApplicationContext(); Application.Run(applicationContext); } catch (Exception ex) { MessageBox.Show(ex.Message, "Program Terminated UnexpectedlyZZ", MessageBoxButtons.OK, MessageBoxIcon.Error); } SingleInstance.Stop(); }