CacheRequest Class

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Specifies properties and patterns that the UI Automation framework caches when an AutomationElement is obtained.

Namespace:   System.Windows.Automation
Assembly:  UIAutomationClient (in UIAutomationClient.dll)

System.Object
  System.Windows.Automation.CacheRequest

[<Sealed>]
type CacheRequest = class end

NameDescription
System_CAPS_pubmethodCacheRequest()

Initializes a new instance of the CacheRequest class.

NameDescription
System_CAPS_pubpropertyAutomationElementMode

Gets or sets a value that specifies whether returned elements should contain full references to the underlying user interface (UI), or only cached information.

System_CAPS_pubpropertySystem_CAPS_staticCurrent

Gets the CacheRequest that is active on the current thread.

System_CAPS_pubpropertyTreeFilter

Gets or sets a value specifying the view of the UI Automation element tree to use when caching.

System_CAPS_pubpropertyTreeScope

Gets or sets a value that specifies whether caching is done only for the root of the subtree, or also for its children or descendants.

NameDescription
System_CAPS_pubmethodActivate()

Sets this CacheRequest as the active specification for the items that are returned when an AutomationElement is requested on the same thread.

System_CAPS_pubmethodAdd(AutomationPattern)

Adds the specified AutomationPattern identifier to this CacheRequest.

System_CAPS_pubmethodAdd(AutomationProperty)

Adds the specified AutomationProperty identifier to this CacheRequest.

System_CAPS_pubmethodClone()

Creates a copy of this CacheRequest.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodPop()

Removes the active CacheRequest from the internal stack for the current thread.

System_CAPS_pubmethodPush()

Places the CacheRequest on the internal state stack, making it the active request on the current thread.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

Retrieving properties and patterns through UI Automation requires cross-process calls that can slow down performance. By caching values of proprieties and patterns in a batch operation, you can enhance the performance of your application.

Create a new cache request by calling the class constructor. The request is populated by repeated calls to the Add method.

Only a single CacheRequest can be active. There are two ways to activate a request:

  • Call Activate on the request. This pushes the request onto the stack, and the request is popped when the object is disposed. To ensure disposal even if an exception is raised, use the return value from Activate within a using block (Using in Microsoft Visual Basic .NET).

  • Put the request onto the internal stack by calling Push. Only the topmost request on the stack is active, and it must be the next one removed from the stack by Pop. Popping the request deactivates it.

UI Automation elements obtained while the request is active will have cached values for the properties and patterns specified.

The following example shows how to use Activate to cache patterns and properties.

No code example is currently available or this language may not be supported.

The following example shows how to use Push and Pop to cache patterns and properties.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 3.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: