當前位置: 首頁>>代碼示例>>Java>>正文


Java Job.cancel方法代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:27,代碼來源:ConvertJobSuspender.java

示例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;
}
 
開發者ID:eclipse,項目名稱:texlipse,代碼行數:51,代碼來源:TexlipseBuilder.java


注:本文中的org.eclipse.core.runtime.jobs.Job.cancel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。