Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / Util / SafeBitVector32.cs / 1 / 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; } #if UNUSED_CODE internal int IntegerValue { get { return _data; } set { #pragma warning disable 0420 Interlocked.Exchange(ref _data, value); #pragma warning restore 0420 } } #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; } } } } 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; } } } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UrlAuthFailedErrorFormatter.cs
- ControlEvent.cs
- complextypematerializer.cs
- AppDomainFactory.cs
- PropertyValueChangedEvent.cs
- MetadataHelper.cs
- SchemeSettingElementCollection.cs
- StreamInfo.cs
- WebPartChrome.cs
- DatePicker.cs
- ContentPlaceHolder.cs
- XamlParser.cs
- CacheSection.cs
- SubclassTypeValidator.cs
- ElementAtQueryOperator.cs
- HostExecutionContextManager.cs
- Events.cs
- PaintEvent.cs
- AuthenticationSchemesHelper.cs
- OleAutBinder.cs
- ObjectDataSourceDisposingEventArgs.cs
- TemplateControlCodeDomTreeGenerator.cs
- InternalDuplexChannelListener.cs
- NegationPusher.cs
- ContentTextAutomationPeer.cs
- AppModelKnownContentFactory.cs
- RightsManagementEncryptionTransform.cs
- LocatorBase.cs
- ToolStripDropDownClosedEventArgs.cs
- SequenceRangeCollection.cs
- TypeUnloadedException.cs
- WebPartConnectionsCancelVerb.cs
- CodeAttributeArgumentCollection.cs
- SoapIncludeAttribute.cs
- ComponentConverter.cs
- XPathArrayIterator.cs
- QuaternionRotation3D.cs
- ResourcePermissionBase.cs
- Int16Animation.cs
- ShadowGlyph.cs
- View.cs
- ImmComposition.cs
- Light.cs
- StringConverter.cs
- RuleValidation.cs
- DataStorage.cs
- CompModSwitches.cs
- EmissiveMaterial.cs
- OleDbParameter.cs
- CalendarDataBindingHandler.cs
- DocumentOrderComparer.cs
- KnownIds.cs
- ScrollableControl.cs
- PixelShader.cs
- CustomGrammar.cs
- _TimerThread.cs
- DataSet.cs
- CharacterShapingProperties.cs
- ProfessionalColorTable.cs
- MimeMultiPart.cs
- ThrowHelper.cs
- RealProxy.cs
- PngBitmapDecoder.cs
- WebPartVerb.cs
- GACMembershipCondition.cs
- DropDownList.cs
- DataGridViewComboBoxCell.cs
- DesignerTransaction.cs
- CodeCastExpression.cs
- UshortList2.cs
- __Error.cs
- SimpleWorkerRequest.cs
- DataGridLinkButton.cs
- DesignSurfaceEvent.cs
- Message.cs
- EntityContainerEntitySet.cs
- CodeMethodReturnStatement.cs
- Identity.cs
- CodeMemberField.cs
- BinarySerializer.cs
- EventRouteFactory.cs
- EnumerationRangeValidationUtil.cs
- SafeFileMapViewHandle.cs
- NamespaceInfo.cs
- PropertyEmitterBase.cs
- RuntimeHelpers.cs
- ChameleonKey.cs
- _emptywebproxy.cs
- XmlSchemaObjectTable.cs
- WriteableBitmap.cs
- ImpersonationOption.cs
- PrivilegedConfigurationManager.cs
- TextServicesContext.cs
- Environment.cs
- GlyphTypeface.cs
- DataGridViewTextBoxColumn.cs
- StringStorage.cs
- OdbcStatementHandle.cs
- XmlSchemaFacet.cs
- XDeferredAxisSource.cs