globalmousekeyhook icon indicating copy to clipboard operation
globalmousekeyhook copied to clipboard

Closing a window when subscribed to mouse events hangs

Open cscorley opened this issue 9 years ago • 2 comments

It seems that whenever I subscribe to any mouse-related events in either a WPF or Forms application, when closing any window created in that application there is a long-lasting hang (30 seconds or more) until either: the application finally closes and shuts down, or I force restart.

Let me be clear: the system is still running fine. I still get instant messages, YouTube remains playing a video, and so on. It's the input that is being garbled up. Alt + F4 on the window closes it fine, it is only when clicking the X.

To reproduce, I simply start a new project in Visual Studio that is either a WPF or Forms application. I then add a Sample.cs class using the code located in the README. I instantiate a Sample object and call Subscribe. The code for either is quite literally:

namespace WindowsFormsApplication1 {
    public partial class Form1 : Form {
        private Sample s;
        public Form1() {
            InitializeComponent();
            s = new Sample();
            s.Subscribe();
        }
    }
}

The WPF one is similar.

When I run this application, in either debug mode or release mode, the main window shows up and I click around. I can see that it's logging things to console, good. Keystrokes are also showing up. I close the MainWindow or Form, and then the hang happens.

Additionally, it does not seem to matter where I instantiate the class. For example, in the WPF case, it does not matter if I do it within the MainWindow.cs or App.cs using the Startup event. In the Forms case, it does not matter if I do it within Program.cs or in Form1.cs.

I'm running Windows 7 Enterprise, SP1, 64-bit.

cscorley avatar Oct 15 '15 15:10 cscorley

Did you ever resolve this issue? I am having the same problem in my program.

antonpup avatar Jun 04 '16 02:06 antonpup

@antonpup no, sorry. Kind of gave up and moved on.

cscorley avatar Jun 04 '16 18:06 cscorley