Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Util / SafeBitVector32.cs / 1305376 / SafeBitVector32.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Threading; namespace System.Web.Util { // // 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; } 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; } } } } internal bool ChangeValue(int bit, bool value) { for (;;) { int oldData = _data; int newData; if (value) { newData = oldData | bit; } else { newData = oldData & ~bit; } if (oldData == newData) { return false; } #pragma warning disable 0420 int result = Interlocked.CompareExchange(ref _data, newData, oldData); #pragma warning restore 0420 if (result == oldData) { return true; } } } } } // 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
- WorkflowOperationContext.cs
- CommonGetThemePartSize.cs
- datacache.cs
- DbConnectionPool.cs
- SoapMessage.cs
- CheckBoxBaseAdapter.cs
- SQLBoolean.cs
- DataGridViewCellValidatingEventArgs.cs
- DataComponentMethodGenerator.cs
- AnnotationObservableCollection.cs
- ApplicationGesture.cs
- HiddenFieldPageStatePersister.cs
- XmlBinaryReader.cs
- LinkedResourceCollection.cs
- Control.cs
- TreeViewAutomationPeer.cs
- LogicalChannelCollection.cs
- GuidTagList.cs
- DrawToolTipEventArgs.cs
- ACL.cs
- TypeReference.cs
- SafePEFileHandle.cs
- InfocardExtendedInformationEntry.cs
- TabPage.cs
- ComplexTypeEmitter.cs
- TransactionFlowOption.cs
- ZipIOExtraFieldPaddingElement.cs
- CharacterString.cs
- ConnectionPoolManager.cs
- AppSettingsSection.cs
- TextEditorDragDrop.cs
- EntityObject.cs
- HttpWriter.cs
- InstanceDataCollection.cs
- Opcode.cs
- DataGridCell.cs
- FormsAuthentication.cs
- PointConverter.cs
- DiscoveryExceptionDictionary.cs
- BamlRecords.cs
- RenderingEventArgs.cs
- CatalogZone.cs
- CellParagraph.cs
- OrderPreservingPipeliningSpoolingTask.cs
- DataGridColumn.cs
- NameObjectCollectionBase.cs
- MetadataArtifactLoaderCompositeFile.cs
- BoundField.cs
- BuildProviderAppliesToAttribute.cs
- XmlTypeMapping.cs
- CultureMapper.cs
- OperatorExpressions.cs
- StringUtil.cs
- ItemContainerProviderWrapper.cs
- KnownBoxes.cs
- CultureMapper.cs
- CommandConverter.cs
- TreeNode.cs
- MeasureItemEvent.cs
- RegionIterator.cs
- StaticFileHandler.cs
- HeaderCollection.cs
- DataGridColumnCollection.cs
- RemoteWebConfigurationHostStream.cs
- EntityCommandExecutionException.cs
- EventRoute.cs
- AliasGenerator.cs
- DocumentAutomationPeer.cs
- HexParser.cs
- StrokeDescriptor.cs
- CodeAttributeDeclarationCollection.cs
- InternalPolicyElement.cs
- StateMachineHelpers.cs
- httpapplicationstate.cs
- XmlSerializableWriter.cs
- SoapHeaderException.cs
- ComPlusInstanceProvider.cs
- UIElementPropertyUndoUnit.cs
- TempEnvironment.cs
- NetStream.cs
- EastAsianLunisolarCalendar.cs
- SourceFileBuildProvider.cs
- BindingExpressionUncommonField.cs
- StrongNameMembershipCondition.cs
- LineBreakRecord.cs
- UnsafeNativeMethods.cs
- QueryContinueDragEventArgs.cs
- PropertyTabAttribute.cs
- DateTimeOffsetStorage.cs
- AnonymousIdentificationModule.cs
- ProcessInputEventArgs.cs
- AuthenticationConfig.cs
- XmlSchemaSimpleContentRestriction.cs
- ExtendLockCommand.cs
- EventRoute.cs
- Util.cs
- ModelItem.cs
- RowToParametersTransformer.cs
- ExtendedPropertyDescriptor.cs
- BackgroundWorker.cs