1

I am developping a multithreaded library in C++, which I compile then to a DLL.

For convenience, I use to name my worker threads with the following method provided by the msdn website : http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx Although I don't get exactly how it works, it does works like a charm as long as I load my DLL among a C++ project.

Now if I want to use it in a C# project, VisualC# breaks on the following line of the sample:

RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );

with this message:

An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in myLibrary.dll
Additional information: External component has thrown an exception.

I unticked every kind of exception in Debug>Exception, but VC# still breaks on this line, then quit my app.

Is there a way of naming thread that is "inter-language-safe"?

Thank you

OoDeLally
  • 552
  • 1
  • 5
  • 21
  • possible duplicate of [SEHException not caught by Try/Catch](http://stackoverflow.com/questions/16436597/sehexception-not-caught-by-try-catch) – Captain Obvlious Mar 21 '14 at 15:06

1 Answers1

0

There was the good answer to my question here, but it disappeared few days after.

Answer is: There is no way to name a thread. Raising this exception is a hack that allows Visual Studio to give it a name in its debugger. Since it is a Visual Studio trick, this method is not exportable.

OoDeLally
  • 552
  • 1
  • 5
  • 21