"Releasing" a File Drop Operation

My app, running on Windows, starts a lengthy operation triggered by a file drop. The app displays progress ok. The fact that it gets unresponsive otherwise is no problem as it does not need to do anything else at this time.

However, I start the processing from the DropObject event, and because of this, I cannot return from this event until after processing finished. Because of this, the application from which I dragged the file freezes also, and further drag’n’drop operations don’t work throughout all applications in the system. Everything goes back to normal, once processing finished and the call to the DropObject terminates.

Is there any way to solve this, other than starting a thread for processing? In classic window programming I would post a message to my message queue and handle it from my main message loop. Is there something like this in RealBasic / Xojo? (I have a license for RealStudio 2011 R4.3 but have several versions of Xojo to experiment with also.)

You could run the operation in a Timer that is activated from the drop object event.

3 Likes

A Thread would be better as it does not block the main thread and thus allows the UI to remain responsive.

Markus on another forum made this post, maybe it will help you.
—————

Maybe someone could point Stefan to this code from xDev 18.4. I couldn’t resist back then and fiddled with the example to make it more responsive (basically the Finder wouldn’t lock up, but the ListBox would). I used two Timers and a Thread, and you can just keep adding files to the ListBox continuously for processing. That enhanced version has been included in the download.

http://www.xdevmag.com/browse/18.4/18407/project18407.zip

i would memory the folderitem, return from event
using a thread or worker to process this item.
you could also use a command line tool to process this file independently.

Thank you all for your replies. I did not think of using a timer to actually run the action. I was only aware that i would need a timer to update the UI if I used a thread to execute the action. Looks like this is the easiest to implement and will cause the least trouble guarding things against access collisions.

I did not look into the details of the Worker class before. In my case I would rather create a console app with all the conversion functionality included, and then dumb the GUI app down to a simple front end for that console app.