2004-12-16

The Task Pattern

Often, you need to write code that performs a time-consuming task, or a task that takes an indeterminate amount of time. This often happens when interacting with the outside world, like executing and waiting for output from another program, sending a file across a network connection, fetching a web page, etc.

The Task Pattern provides a way to monitor long-running tasks, allowing you to give the user feedback (e.g. a progress bar).

Abstract:
"This paper is divided in eight sections: In the first section I examine the problem and motivation for this design pattern. In the second section I explain the pattern in a basic "hello world" manner. Then in the third section I integrate the Task Pattern with the Gang of Four Command, Command Holder and Mediator patterns. In the fourth section I explain how to use the Task Pattern with a worker thread. (The worker thread approach is recommended for production systems.) In the next section the paper explores implementing the pattern with aspects. In the sixth section I present a quick case study of the use of the Task Pattern. In the last two sections the paper does a summary and conclusion and cites references."

The Task Pattern: A Design Pattern for Processing and Monitoring Long-Running Tasks - DeveloperDotStar.com