@Override
	public void run(TaskMonitor taskMonitor) {
		if (taskMonitor == null) {
			return;
		}

		// First get all the search ranges we have to search.  
		List<AddressRange> searchRanges =
			searchDialog.getControlPanel().getRangeWidget().getSearchRange();

		// Get the current cursor location - we'll always start searching from here. 
		Address currentAddr = searchPlugin.getProgramLocation().getByteAddress();

		// See if we're searching forward or backwards.
		boolean forward =
			searchDialog.getControlPanel()
					.getDirectionWidget()
					.getSearchDirection()
					.equals(
						Direction.FORWARD);

		// If we're searching backwards we need to process address ranges in reverse so reverse
		// the list.
		if (!forward) {
			Collections.reverse(searchRanges);
		}

		// Keep track of the range number we're processing, just for display purposes.
		int rangeNum = 0;

		// Now loop over the ranges, searching each in turn.
		for (AddressRange range : searchRanges) {

			rangeNum++;

			// Now, depending on our current cursor location, we may not have to search all of the
			// ranges. ie: if our cursor is beyond the bounds of a range and we're searching in 
			// the forward direction.
			if (forward) {
				if (currentAddr.compareTo(range.getMaxAddress()) >= 0) {
					continue;
				}
			}
			else {
				if (currentAddr.compareTo(range.getMinAddress()) <= 0) {
					continue;
				}
			}

			if (searchRanges.size() > 1) {
				taskMonitor.setMessage(
					"Searching range " + rangeNum + " of " + searchRanges.size());
			}
			else {
				taskMonitor.setMessage("Searching...");
			}

			// And SEARCH.
			InstructionMetadata searchResults =
				searchDialog.getSearchData().search(searchPlugin, range, taskMonitor, forward);

			// If there are results, move the cursor there, otherwise keep looping and check
			// the next range.
			//
			// Note we put these on the swing thread or it will throw off the task monitor display.
			if (searchResults != null) {
				Swing.runLater(() -> {
					goToLocation(searchResults.getAddr());
					searchDialog.getMessagePanel().clear();
				});

				return;
			}

			continue;
		}

		// If we've gone through all the ranges and there are still no results, show an 
		// error message.
		searchDialog.getMessagePanel()
				.setMessageText("No results found", Messages.NORMAL);
		return;

	}
Constructor. 

@param dialog the parent dialog
@param plugin the parent plugin
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/SearchInstructionsTask.java