gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GUI updating while application is working


From: Riccardo Mottola
Subject: GUI updating while application is working
Date: Mon, 23 Jul 2012 10:54:45 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120715 Firefox/14.0.1 SeaMonkey/2.11

Hi,

I have an application which is not multi-threaded (it runs ona single webservice connection, thus the actions are blocked anyway to one after the other). It runs tasks which run in clas methods and which interact with disks and networks. Until now, I was logging all meaningful stuff with NSLog() and I could see progress while the application was running, pretty primitive. I now started to write output on the screen. Right now it is a Logger whcih has a console with a TextView and I print out everything there, scrolling the textview continuously to the last message. In the future, I might also write directly text in dialog boxes and similar things in the future. An action is thus typically cyclical:

while (stuff to do)
  {
     fetch a chunk;
     log information;
     process chunk;
     log information
  }

The problem? There is no GUI update until everything is done.

I could make the application multi-threaded: having only one, controlled, worker-thread that calls the main app just to update the window. This probably works but has a certain effort.

Is there a way to tell the GUI to do some of its stuff? Some way to relinquish control ? It would be a coarse way of course, but before running another loop sequence I can just tell the main runloop to its update stuff?

Should I mess with the current NSRunLoop and tell it to run? Or a similar trick?

This would perhaps also allow to intercept the pressure for a "Cancel" button. Currently I have none, but I might need one in the future.

Incidentally; I have seen that GNUstep apps are even more sensible than Mac apps regarding this: The Mac app with the same code still redraws its windows, the GNUstep application not.

Thanks,
    Riccardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]