Note that there are some explanatory texts on larger screens.

plurals
  1. POdrag into another process
    text
    copied!<p>I am trying to drag an item out into the explorer.<br> The item should result in a file download, so I've used an example I've found on the web to download the file using a <code>CustomDataObject</code> that calls an event when he actually needs the stream, and then my application does the heavy lifting and performs the download.<br> It's been working just fine in a similar Clipboard operation. </p> <p>The actual file download also causes some UI changes in my application. Mostly a "working" icon changing on the form, and also a popup balloon in case of an error. </p> <p>In the clipboard operation I just used <code>InvokeRequired</code> and <code>BeginInvoke</code> when needed, to make sure those UI changes happen on the main thread. In the drag operation, the UI thread is waiting for the return from the <code>DoDragDrop</code>, while the event being raised by the <code>CustomDataObject</code> is being called on a different thread. When I try to call <code>BeginInvoke</code> or <code>Invoke</code> the UI thread is still waiting, and I can't finish the drop. </p> <p>Is there some sample, or a recommended best practice, on how to allow cross-application drag n drop, while accessing the UI of the source application?</p> <h1>UPDATE</h1> <p><a href="http://www.codeproject.com/KB/dotnet/DataObjectEx.aspx" rel="nofollow noreferrer">here</a> is the original CodeProject article with the <code>DataObjectEx</code> I modified for my own use. I just changed the <code>GetFileContents</code> method to call a virtual method which returns a <code>Stream</code> containing the file data, inherited from the class, and overridden that virtual method to get the file from the web. The problem arose when I wanted to change stuff in the UI, while getting the file. As I said earlier - the main UI thread is still "stuck" at the <code>DoDragDrop</code> method call, so I can't invoke it on time to do the UI changes needed by the worker thread before and after downloading the file.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload