Open a dialog asynchronously

I’m building a simple GUI where the user is asked to choose a file for further processing. Because the subsequent steps involved in the process can take some time (loading packages etc), I figured it would be cool if I could arrange it so that the part where the user chooses a file is loaded first, the user will asynchronously choose a file, and in the meantime the required packages will load in the background. Basically something like this:

using Gtk.ShortNames, Reactive
file = Signal("")
@async begin 
    f = open_dialog("Pick a file")
    push!(file, f)
end

using <many packages>
include(<a large amount of code>)

x = map(fun, file) # uses the included codes to process `value(file)` 
  1. The window for the file chooser is blank and unresponsive until the subsequent code finished running, so this makes my whole attempt pointless…
  2. is there a better way to take advantage of this kind of scenario (i.e. we’re basically waiting for the slow human to input something, might as well get cranking with the stuff that does not depend on the UI)?

Thanks!

1 Like