Re: Multithreaded GUI issues

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Smithers" <A@xxxxx> wrote in message
news:%23tSvYZ64HHA.4880@xxxxxxxxxxxxxxxxxxxxxxx
<snip>

RE:
<< I'm not aware of things that you might do with non-GUI objects that
could still affect or otherwise interact with GUI objects>>

I ran into something last week that might be more or less relevant to this
conversation:

The FileSystemWatcher class events are raised, automatically, on separate
threads spawned by the FileSystemWatcher class, itself. So, when updating
UI components from these events, it is possible to get this exception:
"Cross-thread operation not valid: Control 'xyz' accessed from a thread
other than the thread it was created on." Two ways I have found to solve
this: (1) Make use of this.Invoke() to call the code that updates the UI
control, or (2) Set the FileSystemWatcher.SynchronizingObject property to
reference the form class. I have not run into the .SynchronizingObject
property elsewhere, but perhaps other framework classes have it or
something similar.

-S

Yeah, there was one other non-GUI thread event that I had going which was a
System.Timer.Timer.Elapsed event. That's happening in my main application
(non-gui code) which then calls into the GUI. Before doing so, it checks to
make sure that the application main form is non-null and that it has a
message loop (via a boolean I set to true in the OnLoad() and false in
OnClosing()) and then it Invokes into the GUI thread before calling stuff in
the GUI.

So that's all pretty clean.

Really, I think I've isolated all the thread stuff pretty well. I don't see
(and at this point, nProf appears to be backing it up) anywhere that non-GUI
threads can be crossing the line.


.



Relevant Pages

  • Re: zinc GUI event queue problem ...
    ... > both the tasks namely gui (zinc) and non-gui are at same priority. ... > There is delay in receiving event in GUI queue. ...
    (comp.os.vxworks)
  • Re: New Mainframe Blog Site -- mainframeblogger.com
    ... Notice that is supports both GUI and non-GUI and is intended for "network" ... workstation) work via ISPF. ... the non-GUI mode integrates your workstation with your ISPF ...
    (comp.lang.cobol)
  • zinc GUI event queue problem ...
    ... I am using following code to pass event from non-gui thread to gui ... both the tasks namely gui (zinc) and non-gui are at same priority. ... There is delay in receiving event in GUI queue. ...
    (comp.os.vxworks)
  • Re: 2-way communication
    ... If I understand you, then face.pl is your GUI, and Y.pl is a non-GUI ... perl script. ... ambitious method would be to use sockets. ...
    (comp.lang.perl.tk)