What is equivalent to ExitThread (ExitCode) and GetExitCodeThread in C # and .net?

Reading the VS2008 Help File I found out that a clean way to exit a stream (in .net) is either by using the return statement (in C #) or so that the stream reaches the end of the method.

However, I did not find a method or property that would allow me to set the stream exit code and how to retrieve it (as is done using the Win32 API). So the question is: how do I do this with C # and .net?

Thank you for your help.

John.

+4
source share
1 answer

The reason that the underlying Win32 thread primitives are not displayed is to prevent the use of managed code. The CLR team is always working on how to optimize the use of threads and does not include any guarantees regarding the comparison of managed: unmanaged threads 1: 1 (see "Note" on the page of this MSDN . Page, for example). If you really want to do this, you will need to configure P / Invoke wrappers that use the unmanaged thread descriptor from Win32 GetCurrentThread (), or connect to the thread matching process yourself using a custom host. I would not recommend it either, if you absolutely do not need to interact with something that uses stream exit codes and is not controlled by code. Find out another way to smuggle state information around if you can manage it all (or use a parallel task library to abstract the level from bare threads).

+7
source

Source: https://habr.com/ru/post/1347649/


All Articles