c# - Is processes threads (or whole process) suspended -
i check if processes' threads (the whole process) suspended. i'm obtaining each process thread code:
var threads = proc.threads; (int x = 0; x < threads.count; x++) { var thread = threads[x];
however system.diagnostics.threadstate
doesn't contain suspended
, system.threading.threadstate
does. how convert system.diagnostics.threadstate
system.threading.threadstate
, or other method check it? i'm not trying suspend/resume them, want know how process hacker/process explorer that.
microsoft made big mistake in .net version 1.0, added thread.suspend() , resume() methods. methods abused, programmers used them implement thread synchronization. entirely inappropriate. problem usually worked. call suspend() @ unlucky time , you'll freeze thread while buried inside windows call, holding global lock. , causing entire program deadlock.
it not design mistake made, synchronized method on collection classes quite disaster well. misinterpreted "returns thread-safe collection".
live , learn, got fixed in .net 2.0. 1 big overhaul thread may not operating system thread anymore, never got implemented. explains why there two threadstate enumerations, 1 thread (the .net version) , processthread (the operating system version). , closed loophole on programmers abusing suspend/resume, methods declared obsolete. , closed backdoor well, can't find out processthread thread suspended.
feature, not bug. don't make same mistake, knowing thread suspended useless knowledge, may not suspended anymore microsecond later.
Comments
Post a Comment