Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - How to figure out who owns a worker thread that is still running when my app exits? -


not long after upgrading vs2010, application won't shut down cleanly. if close app , hit pause in ide, see this:

alt text

the problem is, there's no context. call stack says [external code], isn't helpful.

here's i've done far try narrow down problem:

  • deleted extraneous plugins minimize number of worker threads launched
  • set breakpoints in code anywhere create worker threads (and delegates + begininvoke, since think labeled "worker thread" in debugger anyway). none hit.
  • set isbackground = true threads

while next brute force step, roll code point didn't happen , on of change logs, isn't terribly efficient. can recommend better way figure out, given notable lack of information presented debugger?

the other things can think of include:

  • read on windbg , try use stop anytime thread started. @ least, thought possible... :)
  • comment out huge blocks of code until app closes properly, start uncommenting until doesn't.

update

perhaps information of use. decided use windbg , attach application. closed it, , switched thread 0 , dumped stack contents. here's have:

threadcount:      6 unstartedthread:  0 backgroundthread: 1 pendingthread:    0 deadthread:       4 hosted runtime:   no                                    preemptive   gc alloc                lock        id  osid threadobj    state gc           context       domain   count apt exception    0    1  1c70 005a65c8      6020 enabled  02dac6e0:02dad7f8 005a03c0     0 sta    2    2  1b20 005b1980      b220 enabled  00000000:00000000 005a03c0     0 mta (finalizer) xxxx    3       08504048     19820 enabled  00000000:00000000 005a03c0     0 ukn xxxx    4       08504540     19820 enabled  00000000:00000000 005a03c0     0 ukn xxxx    5       08516a90     19820 enabled  00000000:00000000 005a03c0     0 ukn xxxx    6       08517260     19820 enabled  00000000:00000000 005a03c0     0 ukn 0:008> ~0s eax=c0674960 ebx=00000000 ecx=00000000 edx=00000000 esi=0040f320 edi=005a65c8 eip=76c37e47 esp=0040f23c ebp=0040f258 iopl=0         nv ei pl nz na po nc cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000202 user32!ntusergetmessage+0x15: 76c37e47 83c404          add     esp,4 0:000> !clrstack os thread id: 0x1c70 (0) child sp ip       call site 0040f274 76c37e47 [inlinedcallframe: 0040f274]  0040f270 6baa8976 domainboundilstubclass.il_stub_pinvoke(system.windows.interop.msg byref, system.runtime.interopservices.handleref, int32, int32)*** warning: unable verify checksum c:\windows\assembly\nativeimages_v4.0.30319_32\windowsbase\d17606e813f01376bd0def23726ecc62\windowsbase.ni.dll  0040f274 6ba924c5 [inlinedcallframe: 0040f274] ms.win32.unsafenativemethods.intgetmessagew(system.windows.interop.msg byref, system.runtime.interopservices.handleref, int32, int32) 0040f2c4 6ba924c5 ms.win32.unsafenativemethods.getmessagew(system.windows.interop.msg byref, system.runtime.interopservices.handleref, int32, int32) 0040f2dc 6ba8e5f8 system.windows.threading.dispatcher.getmessage(system.windows.interop.msg byref, intptr, int32, int32) 0040f318 6ba8d579 system.windows.threading.dispatcher.pushframeimpl(system.windows.threading.dispatcherframe) 0040f368 6ba8d2a1 system.windows.threading.dispatcher.pushframe(system.windows.threading.dispatcherframe) 0040f374 6ba7fba0 system.windows.threading.dispatcher.run() 0040f380 62e6ccbb system.windows.application.rundispatcher(system.object)*** warning: unable verify checksum c:\windows\assembly\nativeimages_v4.0.30319_32\presentationframewo#\7f91eecda3ff7ce478146b6458580c98\presentationframework.ni.dll  0040f38c 62e6c8ff system.windows.application.runinternal(system.windows.window) 0040f3b0 62e6c682 system.windows.application.run(system.windows.window) 0040f3c0 62e6c30b system.windows.application.run() 0040f3cc 001f00bc myapplication.app.main() [c:\code\trunk\myapplication\obj\debug\generatedinternaltypehelper.g.cs @ 24] 0040f608 66c421db [gcframe: 0040f608] 

edit -- not sure if helps, main thread's call stack looks this:

    [managed native transition]   >   windowsbase.dll!ms.win32.unsafenativemethods.getmessagew(ref system.windows.interop.msg msg, system.runtime.interopservices.handleref hwnd, int umsgfiltermin, int umsgfiltermax) + 0x15 bytes       windowsbase.dll!system.windows.threading.dispatcher.getmessage(ref system.windows.interop.msg msg, system.intptr hwnd, int minmessage, int maxmessage) + 0x48 bytes      windowsbase.dll!system.windows.threading.dispatcher.pushframeimpl(system.windows.threading.dispatcherframe frame = {system.windows.threading.dispatcherframe}) + 0x85 bytes      windowsbase.dll!system.windows.threading.dispatcher.pushframe(system.windows.threading.dispatcherframe frame) + 0x49 bytes       windowsbase.dll!system.windows.threading.dispatcher.run() + 0x4c bytes       presentationframework.dll!system.windows.application.rundispatcher(object ignore) + 0x17 bytes       presentationframework.dll!system.windows.application.runinternal(system.windows.window window) + 0x6f bytes      presentationframework.dll!system.windows.application.run(system.windows.window window) + 0x26 bytes      presentationframework.dll!system.windows.application.run() + 0x1b bytes  

i did search on , found posts related wpf guis hanging, , maybe that'll give me more clues.

the worker thread id seeing 0. framework thread , expected - not thread program has "spawned". if attach .net process see this. i'm not sure framework thread - not finalizer thread never thread 0. perhaps jit thread?

what more interesting main thread, appears hanging. concentrate on debugging main thread bottom out. has deadlocked window closed event handler waiting never happen example?

update

after reading stack trace main thread added question, interesting run test bottom out whether main thread stalled or whether idle waiting message (and waiting wm_close never received or never sent).

the code below can used manually send wm_close message application. wait program hang when have shut down, , run code. replace process name own.

update 2

ok, looks main thread , hung not processing wm_close or wm_quit messages.

please try , make smallest application can reproduce issue , post code.

example wm_close\wm_quit app

internal class program {     private const int wm_quit = 0x0012;     private const int wm_close = 0x0010;      [dllimport("user32.dll")]     private static extern bool postmessage(int hhwnd, uint msg, intptr wparam, intptr lparam);      private static void main()     {         process p = getprocess("your process name - no '.exe' required");          closemainwindow(p);     }      private static process getprocess(string name)     {         list<process> processes = process.getprocessesbyname(name).tolist();          if (processes.count != 1)         {             throw new exception(               "expected 1 process name '" + name +               "' found " + processes.count + ".");         }          return processes[0];     }      private static void closemainwindow(process p)     {         postmessage(p, wm_close, "close");     }      private static void quitapplication(process p)     {         postmessage(p, wm_quit, "quit");     }      private static void postmessage(process p, uint message, string name)     {         console.writeline("posting {0} message '{1}'...", name, p.processname);          bool succeeded = postmessage(p.mainwindowhandle.toint32(), message, intptr.zero, intptr.zero);          console.writeline("posted {0} message '{1}' (succeeded:{2}).", name, p.processname, succeeded);     } }  

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -