Long Operations"

From Documentation
Line 1: Line 1:
 
{{ZKDevelopersReferencePageHeader}}
 
{{ZKDevelopersReferencePageHeader}}
Events for the same desktop are processed sequentially. In other words, an event handler will block any following handlers. Worse of all, the user, due to the limitation of HTTP, got no hint but the small processing dialog shown at the left-top corner on the browser.
+
Events for the same desktop are processed sequentially. It simplifies the GUI programming and component development. However, it means an event handler that spends a lot of time to execute will block any following handlers. Worse of all, the user, due to the limitation of HTTP, got no hint but the small busy dialog shown at the left-top corner on the browser.
  
With the echo event and the showBusy method as described in the Echo Events section above, you can provide a more descriptive message and prevent the user from, say, clicking other buttons to slow down the performance further for long operations.
+
There are basically two approaches:
 +
#Handle everything in an event thread and have the user to wait but show more visible message to notice him
 +
#Handle the long operation in an independent thread, such that the user can access other functions
  
However, blocking users from access might not be acceptable for your applications. To prevent the blocking, you have to, like desktop applications, process the long operation in another working thread. Then, report the processing status back the client continuously.
+
The first approach could be done with a technique called ''echo events'' as describe in [[ZK Developer's Reference/UI Patterns/Long Operations/Use Echo Events|the Use Echo Events section]].
  
With ZK, you have four options: server push, suspend and resume, timer, and piggyback.  
+
The second approach can be done in several ways, such as starting a working thread to do the long operation and then using a timer to check if the data ready and show to the client. However, there is a simple approach: use [[ZK Developer's Reference/Event Handling/Event Queues|an event queue]] to run an asynchronous listener as described in [[ZK Developer's Reference/UI Patterns/Long Operations/Use Event Queues|the Use Event Queues section]].
 +
 
 +
In additions to above approaches, there is a special mechanism called piggyback, which could be used to piggy back UI updates without extra network traffic.
  
 
{{ZKDevelopersReferenceHeadingToc}}
 
{{ZKDevelopersReferenceHeadingToc}}
 
{{ZKDevelopersReferencePageFooter}}
 
{{ZKDevelopersReferencePageFooter}}

Revision as of 09:19, 2 December 2010



Events for the same desktop are processed sequentially. It simplifies the GUI programming and component development. However, it means an event handler that spends a lot of time to execute will block any following handlers. Worse of all, the user, due to the limitation of HTTP, got no hint but the small busy dialog shown at the left-top corner on the browser.

There are basically two approaches:

  1. Handle everything in an event thread and have the user to wait but show more visible message to notice him
  2. Handle the long operation in an independent thread, such that the user can access other functions

The first approach could be done with a technique called echo events as describe in the Use Echo Events section.

The second approach can be done in several ways, such as starting a working thread to do the long operation and then using a timer to check if the data ready and show to the client. However, there is a simple approach: use an event queue to run an asynchronous listener as described in the Use Event Queues section.

In additions to above approaches, there is a special mechanism called piggyback, which could be used to piggy back UI updates without extra network traffic.




Last Update : 2010/12/02

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.