Method OpenAndUseWithRetry
- Namespace
- PaintDotNet.Clipboard
- Assembly
- PaintDotNet.Core.dll
OpenAndUseWithRetry<T>(IClipboard, nint, Func<IClipboardTransaction, T>)
Opens a clipboard transaction, passes it to the given callback, and then closes the clipboard transaction. If there is an exception while opening the clipboard or calling the callback, this process is repeated after a short delay. After too many failed attempts, this method will either throw the first exception that was caught (if they are all the same) or an AggregateException (if they are different).
public static T OpenAndUseWithRetry<T>(this IClipboard clipboard, nint hwnd, Func<IClipboardTransaction, T> callback)
Parameters
clipboard
IClipboardhwnd
nintcallback
Func<IClipboardTransaction, T>
Returns
- T
Type Parameters
T
Remarks
The Windows clipboard often returns errors for various reasons, usually because other programs are
accessing it briefly. Because of this it is necessary to retry several times to access it
successfully. This method implements that retry logic for you.
Note that the other clipboard extension methods, such as SetImage(IClipboard, IBitmapSource)
and TryGetText(IClipboard), already implement a retry loop, and do not need to be
used along with this method. You only need to use this method if you want to use the methods on
IClipboardTransaction directly.
OpenAndUseWithRetry<T>(IClipboard, IWin32Window, Func<IClipboardTransaction, T>)
Opens a clipboard transaction, passes it to the given callback, and then closes the clipboard transaction. If there is an exception while opening the clipboard or calling the callback, this process is repeated after a short delay. After too many failed attempts, this method will either throw the first exception that was caught (if they are all the same) or an AggregateException (if they are different).
public static T OpenAndUseWithRetry<T>(this IClipboard clipboard, IWin32Window hwnd, Func<IClipboardTransaction, T> callback)
Parameters
clipboard
IClipboardhwnd
IWin32Windowcallback
Func<IClipboardTransaction, T>
Returns
- T
Type Parameters
T
Remarks
The Windows clipboard often returns errors for various reasons, usually because other programs are
accessing it briefly. Because of this it is necessary to retry several times to access it
successfully. This method implements that retry logic for you.
Note that the other clipboard extension methods, such as SetImage(IClipboard, IBitmapSource)
and TryGetText(IClipboard), already implement a retry loop, and do not need to be
used along with this method. You only need to use this method if you want to use the methods on
IClipboardTransaction directly.
OpenAndUseWithRetry<T>(IClipboard, Func<IClipboardTransaction, T>)
Opens a clipboard transaction, passes it to the given callback, and then closes the clipboard transaction. If there is an exception while opening the clipboard or calling the callback, this process is repeated after a short delay. After too many failed attempts, this method will either throw the first exception that was caught (if they are all the same) or an AggregateException (if they are different).
public static T OpenAndUseWithRetry<T>(this IClipboard clipboard, Func<IClipboardTransaction, T> callback)
Parameters
clipboard
IClipboardcallback
Func<IClipboardTransaction, T>
Returns
- T
Type Parameters
T
Remarks
The Windows clipboard often returns errors for various reasons, usually because other programs are
accessing it briefly. Because of this it is necessary to retry several times to access it
successfully. This method implements that retry logic for you.
Note that the other clipboard extension methods, such as SetImage(IClipboard, IBitmapSource)
and TryGetText(IClipboard), already implement a retry loop, and do not need to be
used along with this method. You only need to use this method if you want to use the methods on
IClipboardTransaction directly.
OpenAndUseWithRetry(IClipboard, nint, Action<IClipboardTransaction>)
Opens a clipboard transaction, passes it to the given callback, and then closes the clipboard transaction. If there is an exception while opening the clipboard or calling the callback, this process is repeated after a short delay. After too many failed attempts, this method will either throw the first exception that was caught (if they are all the same) or an AggregateException (if they are different).
public static void OpenAndUseWithRetry(this IClipboard clipboard, nint hwnd, Action<IClipboardTransaction> callback)
Parameters
clipboard
IClipboardhwnd
nintcallback
Action<IClipboardTransaction>
Remarks
The Windows clipboard often returns errors for various reasons, usually because other programs are
accessing it briefly. Because of this it is necessary to retry several times to access it
successfully. This method implements that retry logic for you.
Note that the other clipboard extension methods, such as SetImage(IClipboard, IBitmapSource)
and TryGetText(IClipboard), already implement a retry loop, and do not need to be
used along with this method. You only need to use this method if you want to use the methods on
IClipboardTransaction directly.
OpenAndUseWithRetry(IClipboard, IWin32Window, Action<IClipboardTransaction>)
Opens a clipboard transaction, passes it to the given callback, and then closes the clipboard transaction. If there is an exception while opening the clipboard or calling the callback, this process is repeated after a short delay. After too many failed attempts, this method will either throw the first exception that was caught (if they are all the same) or an AggregateException (if they are different).
public static void OpenAndUseWithRetry(this IClipboard clipboard, IWin32Window hwnd, Action<IClipboardTransaction> callback)
Parameters
clipboard
IClipboardhwnd
IWin32Windowcallback
Action<IClipboardTransaction>
Remarks
The Windows clipboard often returns errors for various reasons, usually because other programs are
accessing it briefly. Because of this it is necessary to retry several times to access it
successfully. This method implements that retry logic for you.
Note that the other clipboard extension methods, such as SetImage(IClipboard, IBitmapSource)
and TryGetText(IClipboard), already implement a retry loop, and do not need to be
used along with this method. You only need to use this method if you want to use the methods on
IClipboardTransaction directly.
OpenAndUseWithRetry(IClipboard, Action<IClipboardTransaction>)
Opens a clipboard transaction, passes it to the given callback, and then closes the clipboard transaction. If there is an exception while opening the clipboard or calling the callback, this process is repeated after a short delay. After too many failed attempts, this method will either throw the first exception that was caught (if they are all the same) or an AggregateException (if they are different).
public static void OpenAndUseWithRetry(this IClipboard clipboard, Action<IClipboardTransaction> callback)
Parameters
clipboard
IClipboardcallback
Action<IClipboardTransaction>
Remarks
The Windows clipboard often returns errors for various reasons, usually because other programs are
accessing it briefly. Because of this it is necessary to retry several times to access it
successfully. This method implements that retry logic for you.
Note that the other clipboard extension methods, such as SetImage(IClipboard, IBitmapSource)
and TryGetText(IClipboard), already implement a retry loop, and do not need to be
used along with this method. You only need to use this method if you want to use the methods on
IClipboardTransaction directly.