Re: File browser



On Tue, 05 Feb 2008 18:48:04 -0800, Daniele Futtorovic <da.futt.newsLOVELYSPAM@xxxxxxxxxxx> wrote:

Well, you tried doing the initial GUI setup in the main thread and
showing it there, didn't you? It works. Consequently it's not a MUST
rule as the examples of the Win and Mac API you spoke of.

I believe that is the correct conclusion. However, since the API isn't doing what I want, it was my interpretation of the other posts that it was _possible_ that the failure of the API to do what I wanted was due to the improper initialization.

Changing the initialization didn't change the behavior, so I feel I've sufficiently ruled out that hypothesis. But at the time I wrote the post to which you're responding, I hadn't.

As a matter of fact, you probably would get an application to run
properly even if you ignored that rule -- provided you didn't went
overboard with threads, mayhap issued a supplementary repaint() or two
here and there and, most importantly, ran on a single core CPU.

Not on Windows. As I mentioned, messages for a specific window handle are delivered only to the message pump running in the same thread that created the window handle. You must have a message pump in the same thread that created the window handle, no ifs, ands, or buts. And Windows strictly enforces the rule about calling the window procedure; granted, the code that implements the procedure could always call it directly, but if you go through the normal PostMessage/SendMessage API that you're supposed to use, Windows will always cause the execution of the window procedure needed for handling those calls to happen on the same thread that created the window handle.

But I digress...I'm not sure that sort of talk is really appropriate in a Java newsgroup. :)

BUT...

(and in fact, I infer that if you can ensure synchronization then
interacting with the components is fine any time).

Not quite. You should know how slippery beasts synchronisation issues (I
do not primarily mean dead-locks or race-conditions, but memory
visibility issues) can be. I don't think it is possible to tell with
sufficient certainty that you won't have synchronisation problems in
your GUI -- given its sheer complexity.

It may be difficult. But note that I wrote "if you can". You are refuting the statement by trying to assert that you can't. But that's not a logical contradiction of the if/then I offered.

All that said, if you write code that intentially blocks the EDT, and then perform some operation elsewhere on another thread, I would expect that to synchronize a component assuming there are no other threads accessing the component. I'm not saying it's a pretty way to write code, or even a way I would ever attempt. But that's a lot different from saying it's simply not possible or can't work at all.

The question is academic. My intention is always to use the API as it's intended, and not try to abuse it. Doing otherwise is just asking for trouble. But I do like to know the specific details, and I am particularly interested in resolving discrepancies between two sources of information. The unresolved tension makes it hard for me to think otherwise...it's just how I am. I need my world to be well-ordered, with no loose ends. :)

Pete
.



Relevant Pages

  • Re: Error on Exit Sub
    ... this problem just came to our attention a few days ago; ... out any errors from the API call, he wasn't ready for me to start learning ... > determined you need to lock the window, you can achieve the same effect ... The control/form won't disappear, but its internal ...
    (microsoft.public.vb.general.discussion)
  • Learning Quartz API? Am I on the right track here?
    ... The purpose of the API is pretty simple, it just wraps up the platform ... specific details of instancing a window, ... So I'm asking here, #1 is it worth my time to worry about Quartz, ...
    (comp.sys.mac.programmer.help)
  • Re: Drag-and-drop from Windows Explorer?
    ... >that is not a function of delphi but of the win32 api. ... >to register the form as a window that will accept the ... >free the memory via the handle that was given you. ...
    (comp.lang.pascal.delphi.misc)
  • Re: MPEG2 Video Capture to a BMP
    ... >> We have an application that has a propriotary mpeg2 player. ... The API of the ... >video capture from web cam devices, etc. and I think I am on the right path ... >create a capture window and this happens, ...
    (microsoft.public.dotnet.framework)
  • Windows message pump problems
    ... Although I can make calls into the API and do things proactively, when I register a callback for event notification, this callback doesn't get called. ... I am told that if I want event notifications, I must create a window and run a "message pump" on it, and pass the window handle to the API when I register my callback function. ...
    (comp.lang.python)