Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display the number of threads in mono?

I tried the following code which works fine in the Windows CLR:

System.Diagnostics.Process.GetCurrentProcess().Threads.Count

... resulting in something > 0.

However under Mono on OS X or Linux it always results in 0

Is this a bug in Mono or do I need another approach because of platform differences?

like image 284
Akira Avatar asked Jul 29 '12 21:07

Akira


1 Answers

Going straight to the source, it appears that it's not exactly a bug, but is instead completely unimplemented (note the [MonoTODO] attribute on this method).

Your best course of action would be to open a bug against Mono on Xamarin's bug tracker. It's probably not terribly hard to build this, and it seems like someone on the project may be ashamed enough that this isn't done that they'll fix it quickly.

If you need this to work in the meanwhile, I've got a branch on github that implements a fix for this. I'll work with the Mono folks to see whether/how they want to integrate it.

Update: It has been pulled into the master branch of Mono.

like image 189
sblom Avatar answered Oct 04 '22 02:10

sblom