title: Why do CefSharp custom context menu commands not work most of the time?
body: <p>I implemented a custom context menu for CefSharp based on <a href="https://github.com/cefsharp/CefSharp/blob/acef4ab2c3c4b270f79a3f5eaf8135d7699bb486/CefSharp.Wpf.Example/Handlers/MenuHandler.cs" rel="nofollow noreferrer">this example</a> from the CefSharp github page, to get around the issue that events are fired in different threads which resulted in the context menu not closing when clicking outside.</p>
  
  <p>I basically copy pasted it from the original source, just added a few more cases for the commands and it seemed to work at first. However the commands are executed only sometimes (most of the time not).</p>
  
  <p>I added some <code>Console.WriteLine()</code> to the code to check what was going on and it seems that the execution of the command is sometimes canceled before it's finished.</p>
  
  <p>I'm not sure if it is a bug in CefSharp or CEF, or if the example implementation is just incomplete. I tried to remove the <code>menu.Closed</code> handler, just as an experiment but it seem to make no difference.</p>
  
  <p>I searched the internet but couldn't find a bug that matches the description so I guess it's me. Unfortunately I have a hard time wrapping my head around this. If someone could point me in the right direction, or point out the mistake, that would be nice.</p>
  
  <p>My code so far is basically the same as <a href="https://github.com/cefsharp/CefSharp/blob/acef4ab2c3c4b270f79a3f5eaf8135d7699bb486/CefSharp.Wpf.Example/Handlers/MenuHandler.cs" rel="nofollow noreferrer">this example</a> but with all cases for the commands.</p>
  
  <p>I created a simple test application that is nothing but a Window with the Browser but the issue persists, although it happens less frequent. The Visual Studio Project I created for testing can be downloaded <a href="http://www.filedropper.com/browsertest" rel="nofollow noreferrer">here</a>.</p>
  
  <p>If you try to copy a paste a word a few times with the context menu, you should see that it only works about 70% of the time. I guess it happens less often as in my actual app because my actual application is a big monster compared to the test app, and therefore slower.</p>
  
  <p><a href="https://i.stack.imgur.com/vtqTs.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vtqTs.gif" alt="enter image description here"></a></p>
  
  <p>Cef is version 3.3396.1786<br>
  CefSharp.Wpf is version 67.0.0<br>
  OS: Win10 x64  </p>