c# - Reproducing UserPreferenceChanged Event to verify freezing issue fixed -


i've been encountering dreaded userpreferencechanged event ui freezing problem , subsequently working way through possible causes, such as:

but biggest issue having reliably reproducing freeze. i've found can similar reproduction running application in rdp session, exiting session without logging off, , re-connecting rdp session (more not, raises onthemechanged event rather userpreferencechanged event). using method managed freeze application consistently. followed of above advice , corrected issues found. seemed fix problem , handed on qa , using above method not freeze either.

however, customers still seeing freezing issue. getting process dump files them when occurs , can see systemevents.onuserpreferencechanged event has been triggered.

mscorlib.dll!system.threading.waithandle.internalwaitone(system.runtime.interopservices.safehandle waitablesafehandle, long millisecondstimeout, bool hasthreadaffinity, bool exitcontext) system.windows.forms.dll!system.windows.forms.control.waitforwaithandle(system.threading.waithandle waithandle) system.windows.forms.dll!system.windows.forms.control.marshaledinvoke(system.windows.forms.control caller, system.delegate method, object[] args, bool synchronous) system.windows.forms.dll!system.windows.forms.control.invoke(system.delegate method, object[] args) system.dll!microsoft.win32.systemevents.systemeventinvokeinfo.invoke(bool checkfinalization, object[] args) system.dll!microsoft.win32.systemevents.raiseevent(bool checkfinalization, object key, object[] args) system.dll!microsoft.win32.systemevents.onuserpreferencechanged(int msg, system.intptr wparam, system.intptr lparam) system.dll!microsoft.win32.systemevents.windowproc(system.intptr hwnd, int msg, system.intptr wparam, system.intptr lparam) [native managed transition]   [managed native transition] system.windows.forms.dll!system.windows.forms.application.componentmanager.system.windows.forms.unsafenativemethods.imsocomponentmanager.fpushmessageloop(system.intptr dwcomponentid, int reason, int pvloopdata) system.windows.forms.dll!system.windows.forms.application.threadcontext.runmessageloopinner(int reason, system.windows.forms.applicationcontext context) system.windows.forms.dll!system.windows.forms.application.threadcontext.runmessageloop(int reason, system.windows.forms.applicationcontext context) 

so next thought rdp method above not reliable reproduction of issue, , therefore need re-create userpreferencechanged event (wm_settingchange).

so created quick console application following (based on code pinvoke.net)

[dllimport("user32.dll", setlasterror = true, charset = charset.auto)] public static extern intptr sendmessagetimeout(     intptr windowhandle,     uint msg,     intptr wparam,     intptr lparam,     sendmessagetimeoutflags flags,     uint timeout,     out intptr result);  const uint wm_settingchange = 0x1a; intptr innerpinvokeresult; var hwnd_broadcast = new intptr(0xffff);  var pinvokeresult = sendmessagetimeout(hwnd_broadcast, wm_settingchange, intptr.zero,     intptr.zero, sendmessagetimeoutflags.smto_normal, 1000, out innerpinvokeresult);  console.writeline(pinvokeresult); console.writeline(innerpinvokeresult);  console.writeline(pinvokeresult == (intptr) 0 ? "failed" : "success"); 

this seemed work in causes redraw (or refresh?) or explorer windows open on machine.

to verify, added button application, when clicked subscribes event:

systemevents.userpreferencechanged += (s, e) => messagebox.show("user pref"); 

so click button in application subscribe , run console app trigger wm_settingchange , cause application show message box. i've therefore tried use console application part of testing try , reproduce problem - doesn't cause ui freezing!

one thing have noticed if put breakpoint on messagebox.show in test event subscription stack trace not expect be. expected same customers getting. instead is:

testingform.anonymousmethod__40(object o, microsoft.win32.userpreferencechangedeventargs ev) line 1041 [native managed transition]   mscorlib.dll!system.delegate.dynamicinvokeimpl(object[] args) system.dll!microsoft.win32.systemevents.systemeventinvokeinfo.invokecallback(object arg) [native managed transition]   mscorlib.dll!system.delegate.dynamicinvokeimpl(object[] args) system.windows.forms.dll!system.windows.forms.control.invokemarshaledcallbackdo(system.windows.forms.control.threadmethodentry tme) system.windows.forms.dll!system.windows.forms.control.invokemarshaledcallbackhelper(object obj) mscorlib.dll!system.threading.executioncontext.runinternal(system.threading.executioncontext executioncontext, system.threading.contextcallback callback, object state, bool preservesyncctx) mscorlib.dll!system.threading.executioncontext.run(system.threading.executioncontext executioncontext, system.threading.contextcallback callback, object state, bool preservesyncctx) mscorlib.dll!system.threading.executioncontext.run(system.threading.executioncontext executioncontext, system.threading.contextcallback callback, object state) system.windows.forms.dll!system.windows.forms.control.invokemarshaledcallback(system.windows.forms.control.threadmethodentry tme) system.windows.forms.dll!system.windows.forms.control.invokemarshaledcallbacks() system.windows.forms.dll!system.windows.forms.control.wndproc(ref system.windows.forms.message m) system.windows.forms.dll!system.windows.forms.nativewindow.callback(system.intptr hwnd, int msg, system.intptr wparam, system.intptr lparam) [native managed transition]   [managed native transition]  system.windows.forms.dll!system.windows.forms.application.componentmanager.system.windows.forms.unsafenativemethods.imsocomponentmanager.fpushmessageloop(system.intptr dwcomponentid, int reason, int pvloopdata) system.windows.forms.dll!system.windows.forms.application.threadcontext.runmessageloopinner(int reason, system.windows.forms.applicationcontext context) system.windows.forms.dll!system.windows.forms.application.threadcontext.runmessageloop(int reason, system.windows.forms.applicationcontext context) 

so question is: why different stack trace; console application raising userpreferencechange event correctly? if not, how can reproduce it?

i using .net 4.0.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -