Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / SafeBitVector32.cs / 1305376 / SafeBitVector32.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Threading; namespace System.Configuration { // // This is a multithreadsafe version of System.Collections.Specialized.BitVector32. // [Serializable] internal struct SafeBitVector32 { private volatile int _data; internal SafeBitVector32(int data) { this._data = data; } #if UNUSED_CODE internal bool IsAnySet(int bitMask) { int data = _data; return (data & bitMask) != 0; } #endif internal bool this[int bit] { get { int data = _data; return (data & bit) == bit; } set { for (;;) { int oldData = _data; int newData; if (value) { newData = oldData | bit; } else { newData = oldData & ~bit; } #pragma warning disable 0420 int result = Interlocked.CompareExchange(ref _data, newData, oldData); #pragma warning restore 0420 if (result == oldData) { break; } } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Threading; namespace System.Configuration { // // This is a multithreadsafe version of System.Collections.Specialized.BitVector32. // [Serializable] internal struct SafeBitVector32 { private volatile int _data; internal SafeBitVector32(int data) { this._data = data; } #if UNUSED_CODE internal bool IsAnySet(int bitMask) { int data = _data; return (data & bitMask) != 0; } #endif internal bool this[int bit] { get { int data = _data; return (data & bit) == bit; } set { for (;;) { int oldData = _data; int newData; if (value) { newData = oldData | bit; } else { newData = oldData & ~bit; } #pragma warning disable 0420 int result = Interlocked.CompareExchange(ref _data, newData, oldData); #pragma warning restore 0420 if (result == oldData) { break; } } } } } } // 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
- ComplusEndpointConfigContainer.cs
- BackgroundFormatInfo.cs
- TreeNodeBindingCollection.cs
- SharedPersonalizationStateInfo.cs
- HWStack.cs
- MulticastOption.cs
- Attributes.cs
- InfoCardPolicy.cs
- BinaryFormatterSinks.cs
- XPathExpr.cs
- StackOverflowException.cs
- WebConfigurationManager.cs
- DataColumnMapping.cs
- ProtocolInformationWriter.cs
- MLangCodePageEncoding.cs
- XmlILTrace.cs
- CacheMemory.cs
- CapabilitiesState.cs
- FileUtil.cs
- XmlSchemaSimpleTypeList.cs
- RealizationDrawingContextWalker.cs
- GridItemProviderWrapper.cs
- X509IssuerSerialKeyIdentifierClause.cs
- XmlSchemaElement.cs
- DesignerVerb.cs
- GenericIdentity.cs
- SuspendDesigner.cs
- DatasetMethodGenerator.cs
- PrimitiveXmlSerializers.cs
- X509ChainPolicy.cs
- HashJoinQueryOperatorEnumerator.cs
- LateBoundBitmapDecoder.cs
- ComContractElementCollection.cs
- PingReply.cs
- ContentFileHelper.cs
- XmlMapping.cs
- RoutedUICommand.cs
- RecordBuilder.cs
- BindingMAnagerBase.cs
- FixedHyperLink.cs
- Send.cs
- JavascriptCallbackResponseProperty.cs
- DataSourceGeneratorException.cs
- XPathParser.cs
- _AutoWebProxyScriptWrapper.cs
- EdmComplexPropertyAttribute.cs
- DocumentViewerHelper.cs
- HTTPNotFoundHandler.cs
- WindowsFormsSynchronizationContext.cs
- EndEvent.cs
- TextServicesPropertyRanges.cs
- XPathNavigator.cs
- BooleanConverter.cs
- unitconverter.cs
- BitmapImage.cs
- HMAC.cs
- BinaryQueryOperator.cs
- SemanticBasicElement.cs
- XmlTextEncoder.cs
- CalculatedColumn.cs
- XmlSchemaType.cs
- XPathNavigatorReader.cs
- NonceToken.cs
- HierarchicalDataBoundControl.cs
- EntryPointNotFoundException.cs
- CommandDevice.cs
- DataGridViewDataErrorEventArgs.cs
- AnimationClockResource.cs
- Char.cs
- CodePageUtils.cs
- SmiContextFactory.cs
- PkcsUtils.cs
- SelectionRange.cs
- CurrentChangingEventManager.cs
- ScriptReference.cs
- AdapterUtil.cs
- ReferencedType.cs
- SinglePageViewer.cs
- DoubleStorage.cs
- SystemFonts.cs
- InitializationEventAttribute.cs
- TableCell.cs
- WinFormsSecurity.cs
- WebResourceAttribute.cs
- ToolStripGrip.cs
- XmlUtil.cs
- SimpleWebHandlerParser.cs
- Visual.cs
- RSAPKCS1KeyExchangeFormatter.cs
- SqlRemoveConstantOrderBy.cs
- WeakEventTable.cs
- CompModSwitches.cs
- DynamicDiscoSearcher.cs
- HtmlTable.cs
- MemberInfoSerializationHolder.cs
- Helper.cs
- GradientBrush.cs
- OutputCacheProfile.cs
- PrtCap_Public_Simple.cs
- ValueProviderWrapper.cs