Re: Self-configuring classes



On Aug 4, 5:58 am, nebulou...@xxxxxxxxx wrote:
Some obscure blog posting from a blog no-one reads.
That's your evidence against me?

Try Sun's official tutorial then:
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/initial.html

They now say that you should put the creation of GUI
into a separate Runnable, and invoke it via
SwingUtilities.invokeLater.

(One of their old online demo code often deadlocks,
and they finally found out it was because they didn't
postpone everything until the EDT. So now they advocate
all GUI calls must only be done via the EDT unless
the GUI method's javadoc specifically says it is thread-safe)

I haven't reviewed any of the tutorials in some time, mainly because I
long since learned the basics backward and forward, but ISTR the
typical thing for them to do was ... invoke setVisible(true) or show()
on your main application frame from main().

That was the typical thing to do back then.

But it was prone to deadlocks; so now Sun advocates
using SwingUtilities.invokaLater instead.

Eh, until you've presented some UI my understanding has been that the
EDT doesn't even exist yet; it's created lazily. So invokeLater might
be waiting a very long time

No. Wrong again. The thread will be created if needed,
so it won't cause the deadlock that you fear.

Also, ISTR SwingUtilities being a third-party (but commonplace) class
not a standard Java class at all.

No. Wrong again. It's part of Java 5:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/SwingUtilities.html

Now, go away. Your ignorance (and your obvious dishonesty
in your debating tactics is most unwelcome).


.



Relevant Pages

  • Re: Async callback vs events vs ?
    ... This seems to make life complicated and dangerous since there is still a lot I need to do with the information returned including updating the GUI, calling more methods, ... ... The only thing you probably need to really fix is the lack of a call to Control.Invokein your event handler. ... just pass your delegate instance as the state object to the call to BeginInvoke, and then retrieve that from the IAsyncResult.AsyncState property. ... The call to Control.Invoke() does the exact same check, and will simply invoke the delegate directly if InvokeRequired is false. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: CoBOL moved to OO
    ... of a list of file names' by using the Windows GUI and the keyboard alone ... > Alternatively write the collection elements to your text file with a Callback (see ... > invoke FileNames2 "new" returning os-Filenames ...
    (comp.lang.cobol)
  • Re: Async callback vs events vs ?
    ... I suppose I could use the IAsyncResult to pack this information in but - and here is where I lose the plot - all of this is still running under the thread from the threadpool as far as i can tell. ... This seems to make life complicated and dangerous since there is still a lot I need to do with the information returned including updating the GUI, calling more methods, ... ... -- Related to the above, there's no need to check the EndInvokeCalled property; your callback will only be called once per invocation, and you should write the code to only call EndInvokein that callback. ... The call to Control.Invoke() does the exact same check, and will simply invoke the delegate directly if InvokeRequired is false. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: best way to receive callbacks in a GUI from other threads
    ... If the mechanism you're using implies asynchronous behavior then I ... I have a GUI that needs to detail time taken to do jobs ... handing it a callback to call once the job has finished. ... via Invoke. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Is this Threadsafe?
    ... add an item to the dictionary from the GUI ... So, you don't need to use Invoke() for this, assuming you know for sure the "add" method is always executed from the GUI thread. ... Typically you'd cast the anonymous method to "MethodInvoker" for the most common uses of Invoke, but in this case we want to return a value, so we need a delegate type compatible with the anonymous method used here. ... it's not very much overhead and doesn't interfere with the correct operation of the code. ...
    (microsoft.public.dotnet.languages.csharp)