Closed ihorbond closed 4 years ago
Is there a way to make this work with background service ? Service is running on a Local System account and I had to run application loop on a separate thread so that it doesn't halt the service startup but nothing is recorded ?
protected override void OnStart(string[] args) { eventLog1.WriteEntry("In OnStart."); try { Task.Run(() => { ApplicationContext msgLoop = new ApplicationContext(); m_GlobalHook = Hook.GlobalEvents(); m_GlobalHook.KeyPress += (object sender, KeyPressEventArgs e) => eventLog1.WriteEntry($"KeyPress: \t {e.KeyChar}"); Application.Run(msgLoop); }); } catch (Exception ex) { eventLog1.WriteEntry(ex.Message); } }
Closing since I found author's answer
Is there a way to make this work with background service ? Service is running on a Local System account and I had to run application loop on a separate thread so that it doesn't halt the service startup but nothing is recorded ?