Folks i just noticed that this won’t work if i call it on the edt.
[s]Then the time consuming tasks are done before the dialog even shows because of the edt queue like nature. startViewInEDT justs calls invoke later showing the view.
The nature of the method should be to show the dialog the fastest possible in all situations where a progress monitor stream can be used.
Maybe i need a test in the startViewInEDT method?
if(isEDT){
r.run();
}else{
invokeLater®;
}[/s]
(currently startViewInEDT uses invokeLater)
I noticed that the setVisible method is blocking… so the rest of the code never gets executed if i used that runnable in a invokeAndWait or called it directly. Including the code that would call close in the progress monitor (and dispose the view) if it went wrong of if the stream finished. So if i execute directly or use invokeAndWait, the edt is blocked. If i used invokeLater it is not blocked, but the view only displays after getcontentLenght and the rest of the code executes. Just another threading error.
(obviously reordering the statements so the arguments needed are available before calling startViewInEDT is not viable (what happens now if the whole method is called in the EDT). The view must start right then as soon as possible (but not block the rest of the code)).
So what i really need where to make this thread safe is call the whole function code out of the EDT if needed right? But - shit - as the method has a return that is not viable either. The caller would only get the input stream after the popup window was closed.
A notifier in a inputstream static factory saying this method shall not be called in the EDT seems to trust in my ability to read javadocs a bit too much.
3 threads already - edt, one to run this P.O.S. method and the aux turn into a synchronous method into a asynchronous method one.