Code:
/ DotNET / DotNET / 8.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
- RectAnimationUsingKeyFrames.cs
- ProxyGenerator.cs
- XmlRawWriterWrapper.cs
- NegatedConstant.cs
- ValidationPropertyAttribute.cs
- UnsafeNativeMethods.cs
- StyleSelector.cs
- CrossSiteScriptingValidation.cs
- X509CertificateInitiatorClientCredential.cs
- FontFamilyConverter.cs
- CompositionTarget.cs
- ByteStorage.cs
- CalloutQueueItem.cs
- StringSorter.cs
- ScriptBehaviorDescriptor.cs
- HttpRuntime.cs
- TextEditorMouse.cs
- MessageHeaderDescriptionCollection.cs
- ReadOnlyObservableCollection.cs
- HelpKeywordAttribute.cs
- DeviceContexts.cs
- TypeValidationEventArgs.cs
- IfJoinedCondition.cs
- QueryCursorEventArgs.cs
- HwndSourceKeyboardInputSite.cs
- PersistenceException.cs
- DynamicILGenerator.cs
- ApplicationInfo.cs
- ImageSource.cs
- XpsSerializationManager.cs
- ThreadExceptionEvent.cs
- PrintControllerWithStatusDialog.cs
- SerializationSectionGroup.cs
- MergablePropertyAttribute.cs
- HtmlToClrEventProxy.cs
- KeySpline.cs
- ControlBindingsCollection.cs
- WebBrowserContainer.cs
- DataList.cs
- _AcceptOverlappedAsyncResult.cs
- SoapHeaderException.cs
- BufferedWebEventProvider.cs
- TableRowsCollectionEditor.cs
- ReferentialConstraint.cs
- URLMembershipCondition.cs
- DefaultProxySection.cs
- IntranetCredentialPolicy.cs
- FilterElement.cs
- StreamWriter.cs
- BrowserCapabilitiesCompiler.cs
- Rectangle.cs
- RelatedImageListAttribute.cs
- DocumentSchemaValidator.cs
- SmtpReplyReader.cs
- OdbcHandle.cs
- ByteArrayHelperWithString.cs
- MgmtConfigurationRecord.cs
- OperationResponse.cs
- WrapPanel.cs
- DragCompletedEventArgs.cs
- BitVector32.cs
- UnsafeNativeMethods.cs
- DataColumnMapping.cs
- RectKeyFrameCollection.cs
- RowBinding.cs
- WorkflowWebService.cs
- TextRenderer.cs
- SafeFileHandle.cs
- Brush.cs
- MachineKeySection.cs
- NativeMethods.cs
- PermissionSet.cs
- SafePEFileHandle.cs
- SqlReferenceCollection.cs
- ResourcePermissionBase.cs
- FunctionNode.cs
- SQLResource.cs
- TextEndOfLine.cs
- KeyValueInternalCollection.cs
- DataGridComboBoxColumn.cs
- COM2ExtendedTypeConverter.cs
- SplashScreen.cs
- AQNBuilder.cs
- EdmTypeAttribute.cs
- ValidationEventArgs.cs
- HatchBrush.cs
- TaskFileService.cs
- SourceInterpreter.cs
- HtmlTable.cs
- InheritanceAttribute.cs
- CqlWriter.cs
- HttpListener.cs
- TextEndOfParagraph.cs
- DetailsViewActionList.cs
- NamedObject.cs
- IntegerValidator.cs
- SqlCacheDependencyDatabaseCollection.cs
- ResourceType.cs
- PropertyRef.cs
- _ListenerResponseStream.cs