Snap multiple images in for loop, display freezes

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Snap multiple images in for loop, display freezes

Micro-Manager mailing list
Hi,

I am trying to manually program an acquisition in a plugin but the display
window freezes and doesn't show the images until all the images are done in
a for loop. I tried to call snap() in a runnable() but in that case no image
shows up at all.

In a for loop I have this:
                    studio_.album().addImages(studio_.live().snap(false));
store().putImage() and display().show() has the same problem. The for loop
is executed whenever a button is clicked.

Anyone has solution to this?

Thanks,
Bin



--
Sent from: http://micro-manager.3463995.n2.nabble.com/


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Snap multiple images in for loop, display freezes

Stuurman, Nico
Hi Bin,

> I am trying to manually program an acquisition in a plugin but the display
> window freezes and doesn't show the images until all the images are done in
> a for loop. I tried to call snap() in a runnable() but in that case no image
> shows up at all.
>
> In a for loop I have this:
>                      studio_.album().addImages(studio_.live().snap(false));
> store().putImage() and display().show() has the same problem. The for loop
> is executed whenever a button is clicked.

You need to run the code on a different thread.  When the user clicks a
button, the code in its ActionListener will run on the "EDT", a special
thread that handles the display and UI interaction etc.  Updates of
images also happen on the EDT, so if you run your own code there, the
updates will never happen.  The way around this it to start a new thread
in your ActionListener, and execute the code on that new thread.  There
are multiple tutorials online about Java and threads to get you
started.  The Micro-Manager source code is also littered with examples.

Hope this helps!


Best,

Nico


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general