Closed satyris closed 5 years ago
Seems there might be a recursion issue (with the fail-retry task) in the latest update when an exception occurs causing all the events to be invoked.
Have you tried enabling then disabling monitoring after setting the ObservableFormats
using the MonitorClipboard
property?
I'm currently using something like this: `public partial class MainWindow { private SharpClipboard _clipboard = new SharpClipboard();
public MainWindow()
{
_clipboard.InitializeLifetimeService();//Added for testing; didn't change the behavior
_clipboard.ObservableFormats.Texts = true;
_clipboard.ObservableFormats.Files = false;
_clipboard.ObservableFormats.Images = false;
_clipboard.ObservableFormats.Others = false;
_clipboard.ClipboardChanged += _clipboard_ClipboardChanged;
_clipboard.StartMonitoring();
}
private void Options_MonitorClipboardChanged(object sender, EventArgs e)
{
_clipboard.MonitorClipboard = Options.MonitorClipboard;
}
}`
Seems it works fine on my end.
Try comparing yours with the Tests project and see the minor changes you can make. Also, you don't need to use the inherited property InitializeLifetimeService
.
Fixed the multiple event invocations issue. Will be publishing the next update ASAP.
Published v3.3.0
with fix.
Fix works on my side. Thanks!
Although SharpClipboard is set to only observe Texts, the event fires if Images/Other file types are copied using latest Version 3.1.0:
_clipboard.ObservableFormats.Texts = true; _clipboard.ObservableFormats.Files = false; _clipboard.ObservableFormats.Images = false; _clipboard.ObservableFormats.Others = false;