WriteableBitmap.TryLock Method (Duration)


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

Attempts to lock the bitmap, waiting for no longer than the specified length of time.

Namespace:   System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)

public bool TryLock(
	Duration timeout


Type: System.Windows.Duration

A Duration that represents the length of time to wait. A value of 0 returns immediately. A value of Forever blocks indefinitely.

Return Value

Type: System.Boolean

true if the lock was acquired; otherwise, false.

Exception Condition

timeout is set to Automatic.

When a lock is acquired, the behavior of the TryLock method is the same as the Lock method.


for access to unmanaged resources. Security action: Demand. Associated enumeration: SecurityPermissionFlag.UnmanagedCode

.NET Framework
Available since 3.0
Return to top