com.partnersoft.gadgets
Class ActivityProgressWorker

java.lang.Object
  extended by com.partnersoft.gadgets.ActivityProgressWorker
All Implemented Interfaces:
java.lang.Runnable

public abstract class ActivityProgressWorker
extends java.lang.Object
implements java.lang.Runnable

Handles synchronization on tracking the running, paused, and canceled status of a Runnable. It is used by the ActivityProgressControl.

Copyright 2008 Partner Software, Inc.

Author:
Rich Stepanski

Constructor Summary
ActivityProgressWorker()
           
 
Method Summary
 void cancelWork()
          Cancels any remaining work.
 void finishedWorking()
          Marks that all work has been completed by this thread.
 boolean isCanceled()
          Returns if this thread's work has been canceled.
 boolean isPaused()
          Returns if this thread's work should be paused.
 boolean keepRunning()
          Returns if this thread should continue working.
 void setPause(boolean isPaused)
          Sets Pause status for this thread's work.
 void startRunning()
          Marks flag that work is to being.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

ActivityProgressWorker

public ActivityProgressWorker()
Method Detail

cancelWork

public final void cancelWork()
Cancels any remaining work. Thread should stop at the start/end of next loop. Should be called on extending class to cancel any work. Also, clean up should be accounted for after a cancel.


finishedWorking

public final void finishedWorking()
Marks that all work has been completed by this thread. Loop should be exited at next start/end of loop.


setPause

public final void setPause(boolean isPaused)
Sets Pause status for this thread's work. Should be called in extending class's run() as a check to sleep.

Parameters:
isPaused - - True if work should be paused, false otherwise.

isPaused

public final boolean isPaused()
Returns if this thread's work should be paused. Should be called in extending class's run() as a check for each loop.

Returns:
- True if work should be paused, false otherwise.

isCanceled

public final boolean isCanceled()
Returns if this thread's work has been canceled. Should be called in extending class's run() as a check for each loop.Also, clean up should be accounted for after a cancel.

Returns:
True if work is canceled. False otherwise.

startRunning

public final void startRunning()
Marks flag that work is to being. Does not actually start the work. Should be called at the before/beginning of extending class's run(), before any loops.


keepRunning

public final boolean keepRunning()
Returns if this thread should continue working. Has no relation to isCanceled(). Should be called in extending class's run() as a check before each loop. *

Returns:
True if this thread should continue working. False otherwise.