WPF idle application freezes
-
Hi, I'm developing a WPF application that seems to work fine, but after an long inactivity period, when the user clicks something it freezes for a while then it runs normally. This is the only application running in that computer, so I don't know what could be causing this. In my application I need to check the time between user clicks so I'm intercepting Windows messages like this:
void Window_Loaded(object sender, RoutedEventArgs e) { ResetTimeoutChecker();//reset the timer that does something HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle); source.AddHook(new HwndSourceHook(myWndProc)); } private static IntPtr myWndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == 0x0201)//if is a click then reset the timer that does something ResetTimeoutChecker(); return IntPtr.Zero; }
-
Hi, I'm developing a WPF application that seems to work fine, but after an long inactivity period, when the user clicks something it freezes for a while then it runs normally. This is the only application running in that computer, so I don't know what could be causing this. In my application I need to check the time between user clicks so I'm intercepting Windows messages like this:
void Window_Loaded(object sender, RoutedEventArgs e) { ResetTimeoutChecker();//reset the timer that does something HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle); source.AddHook(new HwndSourceHook(myWndProc)); } private static IntPtr myWndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == 0x0201)//if is a click then reset the timer that does something ResetTimeoutChecker(); return IntPtr.Zero; }
Maybe you can use one of the WPF Preview... events on your Window. Since the Window will "see" the event before it happens, you can perform you checks there. Then you can remove all the above code.
Cheers, Karl
» CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home PageJust a grain of sand on the worlds beaches.
-
Maybe you can use one of the WPF Preview... events on your Window. Since the Window will "see" the event before it happens, you can perform you checks there. Then you can remove all the above code.
Cheers, Karl
» CodeProject 2008 MVP My Blog | Mole's Home Page | XAML Power Toys Home PageJust a grain of sand on the worlds beaches.
thanks man, I'm gonna try that right now, but I don't think its gonna make a difference