static void Main(string[] args) { Utils.LoggingUtils.DefaultLogger = new Utils.DatabaseLogger(LogonTracerLib.LogonTracerConfig.Instance.ConnectionString); _logonTracerWorker = new LogonTracerWorker(); _logonTracerWorker.Initialize(); _logonTracerWorker.RegisterSessions(); Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch); //var service = new LogonTracer.LogonTracer(); //service.CanHandleSessionChangeEvent = true; //ServiceBase[] servicesToRun = new ServiceBase[] { service }; //if (Environment.UserInteractive) //{ // Console.CancelKeyPress += (x, y) => service.Stop(); // service.Start(); // Console.WriteLine("Sevice Start"); // Console.ReadKey(); // service.Stop(); // Console.WriteLine("Service Stop"); //} string command = Console.ReadLine(); if (command == "r") { _logonTracerWorker.RegisterSessions(); } else { _logonTracerWorker.StopWatching(); } }
private void stopToolStripMenuItem_Click(object sender, EventArgs e) { _logonTracerWorker.StopWatching(); }
protected override void OnStop() { _logonTracerWorker.StopWatching(); }