Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Util / SystemInfo.cs / 1305376 / SystemInfo.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Util { internal static class SystemInfo { static int _trueNumberOfProcessors; static internal int GetNumProcessCPUs() { if (_trueNumberOfProcessors == 0) { UnsafeNativeMethods.SYSTEM_INFO si; UnsafeNativeMethods.GetSystemInfo(out si); if (si.dwNumberOfProcessors == 1) { _trueNumberOfProcessors = 1; } else { // KERNEL32.DLL:GetCurrentProcess() always returns -1 under NT // Note: not really a handle (no need to CloseHandle()) IntPtr processHandle = UnsafeNativeMethods.INVALID_HANDLE_VALUE; IntPtr processAffinityMask; IntPtr systemAffinityMask; int returnCode = UnsafeNativeMethods.GetProcessAffinityMask( processHandle, out processAffinityMask, out systemAffinityMask); if (returnCode == 0) { _trueNumberOfProcessors = 1; } else { // if cpu affinity is set to a single processor busy waiting is a waste of time int numProcessors = 0; if (IntPtr.Size == 4) { uint mask = (uint) processAffinityMask; for (; mask != 0; mask >>= 1) { if ((mask & 1) == 1) { ++numProcessors; } } } else { ulong mask = (ulong) processAffinityMask; for (; mask != 0; mask >>= 1) { if ((mask & 1) == 1) { ++numProcessors; } } } _trueNumberOfProcessors = numProcessors; } } } Debug.Assert(_trueNumberOfProcessors > 0); return _trueNumberOfProcessors; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ChildDocumentBlock.cs
- GridSplitter.cs
- ScrollChrome.cs
- LongAverageAggregationOperator.cs
- MatrixValueSerializer.cs
- PageAsyncTask.cs
- ScaleTransform3D.cs
- TransformPattern.cs
- HtmlPhoneCallAdapter.cs
- StyleCollection.cs
- RadioButton.cs
- LookupBindingPropertiesAttribute.cs
- TextStore.cs
- OdbcConnectionPoolProviderInfo.cs
- PrintEvent.cs
- AstTree.cs
- XPathNavigatorReader.cs
- MarkupProperty.cs
- LifetimeServices.cs
- TabItemAutomationPeer.cs
- ParallelTimeline.cs
- ImageListUtils.cs
- DataGridTemplateColumn.cs
- SimpleRecyclingCache.cs
- SamlSerializer.cs
- PartManifestEntry.cs
- SqlStream.cs
- UriParserTemplates.cs
- Queue.cs
- SqlNodeAnnotations.cs
- VirtualDirectoryMappingCollection.cs
- CheckBoxFlatAdapter.cs
- MatrixUtil.cs
- ScanQueryOperator.cs
- EventHandlersStore.cs
- HealthMonitoringSectionHelper.cs
- PrimitiveXmlSerializers.cs
- DomNameTable.cs
- XmlElementAttributes.cs
- OnOperation.cs
- Privilege.cs
- CodeParameterDeclarationExpressionCollection.cs
- EntityStoreSchemaFilterEntry.cs
- BaseAddressElementCollection.cs
- Point3DValueSerializer.cs
- SystemTcpConnection.cs
- NativeMethodsCLR.cs
- StringAnimationUsingKeyFrames.cs
- ObjectReaderCompiler.cs
- NativeWindow.cs
- StreamSecurityUpgradeProvider.cs
- SystemWebSectionGroup.cs
- SqlDataSourceSelectingEventArgs.cs
- CacheAxisQuery.cs
- IisTraceListener.cs
- SortedSet.cs
- ResXDataNode.cs
- MarshalByRefObject.cs
- BuildManager.cs
- ImageMap.cs
- Process.cs
- CodeArrayIndexerExpression.cs
- OutputCacheSection.cs
- ZipIOExtraFieldPaddingElement.cs
- BigInt.cs
- XD.cs
- OperationSelectorBehavior.cs
- DataGridViewCellConverter.cs
- GridViewColumnHeaderAutomationPeer.cs
- RowUpdatedEventArgs.cs
- WebPartZoneBase.cs
- LookupNode.cs
- BinaryObjectReader.cs
- ControlCodeDomSerializer.cs
- _SafeNetHandles.cs
- SecurityDescriptor.cs
- ResourceDescriptionAttribute.cs
- ExponentialEase.cs
- ProfilePropertyNameValidator.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- connectionpool.cs
- OletxTransactionManager.cs
- MarkupWriter.cs
- DetailsView.cs
- SimpleBitVector32.cs
- SiteMapPathDesigner.cs
- HtmlElementErrorEventArgs.cs
- CryptographicAttribute.cs
- DataRowCollection.cs
- EdmPropertyAttribute.cs
- ResourceDefaultValueAttribute.cs
- DataGridViewTextBoxColumn.cs
- HyperLink.cs
- XmlChildEnumerator.cs
- HtmlElementCollection.cs
- UnsafeNativeMethods.cs
- ChildrenQuery.cs
- DetailsViewPageEventArgs.cs
- _AutoWebProxyScriptWrapper.cs
- ThreadExceptionEvent.cs