Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / System / Windows / Threading / DispatcherFrame.cs / 1305600 / DispatcherFrame.cs
using System; using System.Security; namespace System.Windows.Threading { ////// Representation of Dispatcher frame. /// public class DispatcherFrame : DispatcherObject { ////// Critical: This code exists to ensure that the static variables initialized /// do not cause security violations.The reason this comes into existance is because /// of the call to RegisterWindowMessage /// TreatAsSafe:This is safe to call /// [SecurityCritical,SecurityTreatAsSafe] static DispatcherFrame() { } ////// Constructs a new instance of the DispatcherFrame class. /// public DispatcherFrame() : this(true) { } ////// Constructs a new instance of the DispatcherFrame class. /// /// /// Indicates whether or not this frame will exit when all frames /// are requested to exit. /// /// Dispatcher frames typically break down into two categories: /// 1) Long running, general purpose frames, that exit only when /// told to. These frames should exit when requested. /// 2) Short running, very specific frames that exit themselves /// when an important criteria is met. These frames may /// consider not exiting when requested in favor of waiting /// for their important criteria to be met. These frames /// should have a timeout associated with them. /// public DispatcherFrame(bool exitWhenRequested) { _exitWhenRequested = exitWhenRequested; _continue = true; } ////// Indicates that this dispatcher frame should exit. /// ////// Critical - calls a critical method - postThreadMessage. /// PublicOK - all we're doing is posting a current message to our thread. /// net effect is the dispatcher "wakes up" /// and uses the continue flag ( which may have just changed). /// public bool Continue { get { // This method is free-threaded. // First check if this frame wants to continue. bool shouldContinue = _continue; if(shouldContinue) { // This frame wants to continue, so next check if it will // respect the "exit requests" from the dispatcher. if(_exitWhenRequested) { Dispatcher dispatcher = Dispatcher; // This frame is willing to respect the "exit requests" of // the dispatcher, so check them. if(dispatcher._exitAllFrames || dispatcher._hasShutdownStarted) { shouldContinue = false; } } } return shouldContinue; } [SecurityCritical] set { // This method is free-threaded. _continue = value; // Post a message so that the message pump will wake up and // check our continue state. Dispatcher.BeginInvoke(DispatcherPriority.Send, (DispatcherOperationCallback) delegate(object unused) {return null;}, null); } } private bool _exitWhenRequested; private bool _continue; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Security; namespace System.Windows.Threading { ////// Representation of Dispatcher frame. /// public class DispatcherFrame : DispatcherObject { ////// Critical: This code exists to ensure that the static variables initialized /// do not cause security violations.The reason this comes into existance is because /// of the call to RegisterWindowMessage /// TreatAsSafe:This is safe to call /// [SecurityCritical,SecurityTreatAsSafe] static DispatcherFrame() { } ////// Constructs a new instance of the DispatcherFrame class. /// public DispatcherFrame() : this(true) { } ////// Constructs a new instance of the DispatcherFrame class. /// /// /// Indicates whether or not this frame will exit when all frames /// are requested to exit. /// /// Dispatcher frames typically break down into two categories: /// 1) Long running, general purpose frames, that exit only when /// told to. These frames should exit when requested. /// 2) Short running, very specific frames that exit themselves /// when an important criteria is met. These frames may /// consider not exiting when requested in favor of waiting /// for their important criteria to be met. These frames /// should have a timeout associated with them. /// public DispatcherFrame(bool exitWhenRequested) { _exitWhenRequested = exitWhenRequested; _continue = true; } ////// Indicates that this dispatcher frame should exit. /// ////// Critical - calls a critical method - postThreadMessage. /// PublicOK - all we're doing is posting a current message to our thread. /// net effect is the dispatcher "wakes up" /// and uses the continue flag ( which may have just changed). /// public bool Continue { get { // This method is free-threaded. // First check if this frame wants to continue. bool shouldContinue = _continue; if(shouldContinue) { // This frame wants to continue, so next check if it will // respect the "exit requests" from the dispatcher. if(_exitWhenRequested) { Dispatcher dispatcher = Dispatcher; // This frame is willing to respect the "exit requests" of // the dispatcher, so check them. if(dispatcher._exitAllFrames || dispatcher._hasShutdownStarted) { shouldContinue = false; } } } return shouldContinue; } [SecurityCritical] set { // This method is free-threaded. _continue = value; // Post a message so that the message pump will wake up and // check our continue state. Dispatcher.BeginInvoke(DispatcherPriority.Send, (DispatcherOperationCallback) delegate(object unused) {return null;}, null); } } private bool _exitWhenRequested; private bool _continue; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpInputStream.cs
- PartManifestEntry.cs
- HttpRuntimeSection.cs
- TypefaceCollection.cs
- OleDbRowUpdatingEvent.cs
- ConfigurationLoaderException.cs
- ResolveResponseInfo.cs
- GreenMethods.cs
- Int64Storage.cs
- MemoryResponseElement.cs
- SpeechSynthesizer.cs
- Canvas.cs
- RectangleF.cs
- TextServicesCompartment.cs
- EntryPointNotFoundException.cs
- WebPartVerb.cs
- DataGridViewSelectedCellCollection.cs
- SynchronizingStream.cs
- WasHttpModulesInstallComponent.cs
- DetailsViewUpdateEventArgs.cs
- Oid.cs
- ScriptingRoleServiceSection.cs
- SqlRowUpdatingEvent.cs
- SignerInfo.cs
- DifferencingCollection.cs
- ExpressionBuilderContext.cs
- FlowDocumentReader.cs
- WebFaultClientMessageInspector.cs
- FactoryMaker.cs
- ColorBuilder.cs
- HandleCollector.cs
- SystemIPGlobalStatistics.cs
- SiteOfOriginContainer.cs
- ISAPIRuntime.cs
- AnnotationResourceCollection.cs
- RemotingClientProxy.cs
- MenuRendererClassic.cs
- FocusWithinProperty.cs
- MiniMapControl.xaml.cs
- XmlCompatibilityReader.cs
- MimeParameters.cs
- EdgeModeValidation.cs
- SettingsBase.cs
- VisualBrush.cs
- EnumConverter.cs
- Misc.cs
- ListItem.cs
- ResourcePermissionBaseEntry.cs
- Assembly.cs
- ScriptingWebServicesSectionGroup.cs
- XPathBuilder.cs
- HttpHandlerAction.cs
- UserUseLicenseDictionaryLoader.cs
- CommandBindingCollection.cs
- PageDeviceFont.cs
- GetWinFXPath.cs
- HtmlTextArea.cs
- AlphabeticalEnumConverter.cs
- ElementAction.cs
- ColumnReorderedEventArgs.cs
- Token.cs
- KeyedByTypeCollection.cs
- ActivityInterfaces.cs
- SocketPermission.cs
- smtpconnection.cs
- OdbcConnectionFactory.cs
- WsdlExporter.cs
- DesignerOptionService.cs
- XdrBuilder.cs
- FontNamesConverter.cs
- CreateParams.cs
- PointAnimationUsingKeyFrames.cs
- DependencySource.cs
- DataGridItemEventArgs.cs
- ProcessManager.cs
- SafeRegistryHandle.cs
- SelectionWordBreaker.cs
- StateValidator.cs
- MyContact.cs
- BaseCodeDomTreeGenerator.cs
- Int64.cs
- TaiwanLunisolarCalendar.cs
- CryptoApi.cs
- basemetadatamappingvisitor.cs
- RowType.cs
- DeviceSpecificDesigner.cs
- AuthStoreRoleProvider.cs
- ReadOnlyDataSourceView.cs
- QilTypeChecker.cs
- MD5CryptoServiceProvider.cs
- DataSourceSelectArguments.cs
- DEREncoding.cs
- OptimalTextSource.cs
- DesignBindingEditor.cs
- FilterRepeater.cs
- Propagator.ExtentPlaceholderCreator.cs
- QualifiedCellIdBoolean.cs
- PasswordBox.cs
- SatelliteContractVersionAttribute.cs
- AdRotator.cs