public synchronized void setDelegate(TaskMonitor newDelegate) {

		// if the existing monitor has already been cancelled, then do not apply the state
		if (delegate.isCancelled()) {
			newDelegate.cancel();
			return;
		}

		for (CancelledListener l : listeners) {
			newDelegate.addCancelledListener(l);
			delegate.removeCancelledListener(l);
		}

		if (delegate.isIndeterminate()) {
			newDelegate.setIndeterminate(true);
		}
		else {
			newDelegate.setIndeterminate(false);
			newDelegate.initialize(delegate.getMaximum());
		}

		newDelegate.setProgress(delegate.getProgress());
		newDelegate.setMessage(delegate.getMessage());
		newDelegate.setCancelEnabled(delegate.isCancelEnabled());

		this.delegate = newDelegate;
	}
Sets the delegate of this wrapper to be the new value.  The new delegate will be 
initialized with the current values of the existing delegate.

@param newDelegate the new delegate
Ghidra/Framework/Generic/src/main/java/ghidra/util/task/WrappingTaskMonitor.java