multithreading - What's the equivalent of ExitThread(ExitCode) and GetExitCodeThread in C# & .net? -
reading vs2008 file i've figured out clean way of exiting thread (in .net) either using return statement (in c#) or letting thread reach end of method.
however, have not found method or property allow me set thread's exit code nor way retrieve (as done using win32 api). therefore, question is, how do using c# , .net ?
thank help,
john.
the reason underlying win32 thread primitives aren't exposed prevent managed code relying on them. clr team working on ways optimize thread usage, , includes no guarantees 1:1 managed:unmanaged thread mapping (see "note" on this msdn page, instance). if want anyway, you'll need set p/invoke wrappers use unmanaged thread handle win32 getcurrentthread(), or hook thread mapping process custom host. wouldn't recommend either, unless absolutely have interop uses thread exit codes , isn't managed code-aware. figure out way smuggle state info around if can managed (or use task parallel library abstract level bare threads).
Comments
Post a Comment