Silverlight: How to get ProcessorCount?

I have a computationally intensive task that users can perform using a Silverlight application. This is a very simple task to parallelize.

My problem is that System.Environment.ProcessorCount is security critical, so I cannot verify this easily.

I do not want just QueueUserWorkItem, because I do not want to have more than the number of executable processors - this will not help.

One workaround is described below: http://www.codeproject.com/KB/silverlight/multicore.aspx

But this is a bit hacky, and it would work a bit to make it reliable enough for 4 or 8 threading systems.

What is the “right” way to solve this? Or is Silverlight just out of luck?

+3
source share
2 answers

The fact that this method is SecurityCritical instead of SecuritySafeCritical is most likely an artifact of the fact that at some point the version of the desktop version of the .NET Framework required the EnvironmentPermission to receive this data.

We have since softened demand on the desktop side, so it actually makes sense to be SafeCritical for Silverlight. I raised this as a problem that we need to fix in a future version of Siverlight, and it looks like we can do it.

, , , SafeCritical Critical Silverlight, Microsoft Connect. , , .

, , - .

Silverlight 4.

+3

, - . , . , , , , , 2 . , , , , .

, , - , , , 7zip. 2+ , , , . clunkier, , , , 4+ , .

+1

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


All Articles