MouseHookListener slow/laggy

Nov 26, 2011 at 10:55 AM


When i hook up the mouse (A) then normal mousemove events in my wpf window becomes substantially slower (B). 

What I am doing in the wpf mousemove handler is drawing a horizontal line where the mouse is, and when the hooks are off it is nice and smooth, and follows my mouse fast.

However, when the hooks are enabled, then the it takes awhile for the horizontal line to appear in the moved location, noticeably after i have moved the mouse i.e. significantly lag is introduced (refresh rate of the mouse tracing poor).

And note it does not matter what i do under _mouseHookListener_MouseMoveExt, in fact i made it empty and the lagginess is still there.

As soon as i do not hook mouse any more, performance returns to normal.


What could i do?


A) When hook mouse up

_mouseHookListener = new MouseHookListener(new GlobalHooker());
_mouseHookListener.MouseMoveExt += _mouseHookListener_MouseMoveExt;
_mouseHookListener.Enabled = true;


B) Handling normal mousemove performance becomes substantially lower

void WpfUserControlMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
              // doing things here becomes much slower