本文整理匯總了Java中org.eclipse.core.runtime.jobs.Job.cancel方法的典型用法代碼示例。如果您正苦於以下問題:Java Job.cancel方法的具體用法?Java Job.cancel怎麽用?Java Job.cancel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.runtime.jobs.Job
的用法示例。
在下文中一共展示了Job.cancel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: suspendJob
import org.eclipse.core.runtime.jobs.Job; //導入方法依賴的package包/類
static void suspendJob(Job job, long scheduleDelay) {
if (!isConvertJob.apply(job)) {
return;
}
synchronized (suspendedJobs) {
if (!suspended.get()) {
return;
}
}
// cancel() must be done outside of our synchronization barrier as may trigger events
// (and even scheduling other jobs)
if (job.cancel()) {
// Cancel should always succeed since the job is not running yet
synchronized (suspendedJobs) {
// check in case the situation has changed during the cancellation
if (suspended.get()) {
suspendedJobs.add(new SuspendedJob(job, scheduleDelay));
} else {
// we've since been resumed, so reschedule this job right away
job.schedule(scheduleDelay);
}
}
} else {
logger.log(Level.SEVERE, "job already running: " + job);
}
}
示例2: build
import org.eclipse.core.runtime.jobs.Job; //導入方法依賴的package包/類
/**
* Build the project.
*
* @see IncrementalProjectBuilder.build
*/
@Override
protected IProject[] build(int kind, Map args,
IProgressMonitor monitor) throws CoreException {
final IProject project = getProject();
final ProjectFileTracking fileTracking = new ProjectFileTracking(project);
final OutputFileManager fileManager = new OutputFileManager(project, fileTracking);
Object rebuild = TexlipseProperties.getSessionProperty(project,
TexlipseProperties.FORCED_REBUILD);
// Wait for all scheduled parser jobs, since they could change relevant
// session properties
for (Job parser : Job.getJobManager().find(TexDocumentModel.PARSER_FAMILY)) {
int state = parser.getState();
if (state == Job.WAITING || state == Job.SLEEPING) {
// If waiting, run immediately
parser.cancel();
parser.schedule();
}
try {
parser.join();
} catch (InterruptedException e) {
}
}
if (rebuild == null && fileManager.isUpToDate()) {
return null;
}
BuilderRegistry.clearConsole();
Object s = TexlipseProperties.getProjectProperty(project,
TexlipseProperties.PARTIAL_BUILD_PROPERTY);
if (s != null) {
partialBuild(project, fileManager, monitor);
} else {
buildFile(project, null, fileManager, monitor);
}
TexlipseProperties.setSessionProperty(project,
TexlipseProperties.FORCED_REBUILD, null);
return null;
}