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
- StopRoutingHandler.cs
- StateInitializationDesigner.cs
- WebHttpBinding.cs
- GlobalDataBindingHandler.cs
- ElementHost.cs
- GeometryModel3D.cs
- StrokeCollection2.cs
- XDeferredAxisSource.cs
- Matrix3DStack.cs
- ResourceBinder.cs
- GrabHandleGlyph.cs
- HostingEnvironmentSection.cs
- SqlClientFactory.cs
- ListenDesigner.cs
- SimpleTypeResolver.cs
- CapabilitiesPattern.cs
- UnsafeNativeMethods.cs
- StaticTextPointer.cs
- DPCustomTypeDescriptor.cs
- SQLMoneyStorage.cs
- MessageAction.cs
- AutomationPeer.cs
- BuildManager.cs
- SmtpNegotiateAuthenticationModule.cs
- ByteStorage.cs
- CachedBitmap.cs
- SocketPermission.cs
- SponsorHelper.cs
- AccessDataSource.cs
- WSHttpTransportSecurityElement.cs
- NativeWrapper.cs
- HttpProfileBase.cs
- NamedPipeActivation.cs
- BitmapInitialize.cs
- SqlColumnizer.cs
- CacheAxisQuery.cs
- CmsInterop.cs
- WSDualHttpBinding.cs
- SqlStream.cs
- Span.cs
- ValidateNames.cs
- SctClaimDictionary.cs
- SHA384CryptoServiceProvider.cs
- SignerInfo.cs
- FlagsAttribute.cs
- Clock.cs
- ApplicationHost.cs
- WriteableBitmap.cs
- BrowserTree.cs
- SevenBitStream.cs
- UriPrefixTable.cs
- HebrewCalendar.cs
- SafeNativeMethodsMilCoreApi.cs
- ReturnType.cs
- BulletedListEventArgs.cs
- TreeNodeStyleCollection.cs
- RNGCryptoServiceProvider.cs
- GCHandleCookieTable.cs
- DataContractSet.cs
- MSAAWinEventWrap.cs
- PtsCache.cs
- SharedPersonalizationStateInfo.cs
- GridViewColumnHeaderAutomationPeer.cs
- ServiceReference.cs
- InvalidateEvent.cs
- HttpModule.cs
- DbProviderFactory.cs
- RectangleGeometry.cs
- VariantWrapper.cs
- OLEDB_Util.cs
- CapabilitiesUse.cs
- CodeDomLoader.cs
- UriScheme.cs
- HttpModuleCollection.cs
- CollectionDataContract.cs
- ConstraintCollection.cs
- Scheduling.cs
- UnsafeNativeMethods.cs
- SortedDictionary.cs
- WorkflowStateRollbackService.cs
- DatePickerDateValidationErrorEventArgs.cs
- Nodes.cs
- HWStack.cs
- IndicCharClassifier.cs
- InfoCardKeyedHashAlgorithm.cs
- Collection.cs
- StringResourceManager.cs
- CodeDirectiveCollection.cs
- ScrollBarRenderer.cs
- TextEndOfParagraph.cs
- DocumentViewerBaseAutomationPeer.cs
- Pointer.cs
- MetadataSection.cs
- DocumentEventArgs.cs
- PageThemeBuildProvider.cs
- DefaultDialogButtons.cs
- DynamicValueConverter.cs
- ContentPlaceHolder.cs
- SortAction.cs
- PeerName.cs