Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Base / System / Windows / Threading / DispatcherFrame.cs / 1 / 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
- CorrelationTokenInvalidatedHandler.cs
- SchemaMapping.cs
- DefaultIfEmptyQueryOperator.cs
- QueryStringParameter.cs
- TextPattern.cs
- RSAPKCS1SignatureFormatter.cs
- AsynchronousChannelMergeEnumerator.cs
- HtmlInputPassword.cs
- SqlDataSourceEnumerator.cs
- SpeechDetectedEventArgs.cs
- RootBuilder.cs
- AccessViolationException.cs
- SortKey.cs
- ViewGenResults.cs
- Debug.cs
- WebContext.cs
- TraceHwndHost.cs
- BindStream.cs
- ClipboardData.cs
- Module.cs
- HttpCachePolicyWrapper.cs
- SecurityContextKeyIdentifierClause.cs
- VideoDrawing.cs
- StoragePropertyMapping.cs
- PrinterUnitConvert.cs
- VisualBasicImportReference.cs
- XmlSchemaSimpleContentRestriction.cs
- SecureUICommand.cs
- LicenseException.cs
- HeaderedContentControl.cs
- ObjectViewEntityCollectionData.cs
- BridgeDataRecord.cs
- CustomSignedXml.cs
- BinHexEncoding.cs
- DuplicateDetector.cs
- WebRequest.cs
- ExtensibleClassFactory.cs
- TogglePattern.cs
- QilInvokeEarlyBound.cs
- PackagePart.cs
- OleDbPropertySetGuid.cs
- ResourcePool.cs
- DiscoveryClientDuplexChannel.cs
- ToolBar.cs
- Point3DAnimation.cs
- ChannelManager.cs
- SynchronizedDispatch.cs
- HttpCapabilitiesEvaluator.cs
- HttpRuntimeSection.cs
- BuildProvidersCompiler.cs
- Control.cs
- ToolstripProfessionalRenderer.cs
- ListParagraph.cs
- XmlHierarchicalEnumerable.cs
- CallbackTimeoutsElement.cs
- ServiceModelEnumValidatorAttribute.cs
- Point4D.cs
- WindowsStartMenu.cs
- EntityTypeEmitter.cs
- IconBitmapDecoder.cs
- SafeSystemMetrics.cs
- XmlILOptimizerVisitor.cs
- ColumnResult.cs
- WebExceptionStatus.cs
- InfoCardSymmetricAlgorithm.cs
- OracleDataAdapter.cs
- dataSvcMapFileLoader.cs
- ComponentDispatcher.cs
- HijriCalendar.cs
- ProcessHostFactoryHelper.cs
- EventLogPermissionAttribute.cs
- FilePrompt.cs
- PostBackOptions.cs
- CheckBoxRenderer.cs
- DataServiceClientException.cs
- Convert.cs
- ApplicationManager.cs
- VisualStyleInformation.cs
- TextProperties.cs
- UriExt.cs
- WebReferencesBuildProvider.cs
- GridViewItemAutomationPeer.cs
- _ConnectOverlappedAsyncResult.cs
- CryptoApi.cs
- PcmConverter.cs
- TextPointer.cs
- CopyNamespacesAction.cs
- MarkupProperty.cs
- ActivityExecutionWorkItem.cs
- MexTcpBindingElement.cs
- MailAddressParser.cs
- BamlStream.cs
- ContentPresenter.cs
- SvcMapFileLoader.cs
- FamilyMap.cs
- InputProcessorProfiles.cs
- QuaternionRotation3D.cs
- Optimizer.cs
- Button.cs
- ObjectStateFormatter.cs