com.google.gwt.user.client.Timer.cancel()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中com.google.gwt.user.client.Timer.cancel()方法的一些代码示例,展示了Timer.cancel()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timer.cancel()方法的具体详情如下:
包路径:com.google.gwt.user.client.Timer
类名称:Timer
方法名:cancel

Timer.cancel介绍

[英]Cancels this timer. If the timer is not running, this is a no-op.
[中]取消这个计时器。如果计时器没有运行,这是禁止操作。

代码示例

代码示例来源:origin: libgdx/libgdx

/** Set whether or not resize checking is enabled. If disabled, elements will still be resized on window events, but the timer
 * will not check their dimensions periodically.
 * 
 * @param enabled true to enable the resize checking timer */
public void setResizeCheckingEnabled (boolean enabled) {
  if (enabled && !resizeCheckingEnabled) {
    resizeCheckingEnabled = true;
    if (windowHandler == null) {
      windowHandler = Window.addResizeHandler(this);
    }
    resizeCheckTimer.schedule(resizeCheckDelay);
  } else if (!enabled && resizeCheckingEnabled) {
    resizeCheckingEnabled = false;
    if (windowHandler != null) {
      windowHandler.removeHandler();
      windowHandler = null;
    }
    resizeCheckTimer.cancel();
  }
}

代码示例来源:origin: libgdx/libgdx

/** Set whether or not resize checking is enabled. If disabled, elements will still be resized on window events, but the timer
 * will not check their dimensions periodically.
 * 
 * @param enabled true to enable the resize checking timer */
public void setResizeCheckingEnabled (boolean enabled) {
  if (enabled && !resizeCheckingEnabled) {
    resizeCheckingEnabled = true;
    if (windowHandler == null) {
      windowHandler = Window.addResizeHandler(this);
    }
    resizeCheckTimer.schedule(resizeCheckDelay);
  } else if (!enabled && resizeCheckingEnabled) {
    resizeCheckingEnabled = false;
    if (windowHandler != null) {
      windowHandler.removeHandler();
      windowHandler = null;
    }
    resizeCheckTimer.cancel();
  }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

private void cancelAnimationFrame(AnimationHandle requestId) {
 // Remove the request from the list.
 animationRequests.remove(requestId);
 // Stop the timer if there are no more requests.
 if (animationRequests.size() == 0) {
  timer.cancel();
 }
}

代码示例来源:origin: org.jboss.errai/errai-bus

private List<Message> getDeferredToSend() {
 throttleTimer.cancel();
 try {
  return new ArrayList<Message>(heldMessages);
 }
 finally {
  heldMessages.clear();
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Cancels a pending request.  Note that if you are using preset ID's, this
 * will not work, since there is no way of knowing if there are other
 * requests pending (or have already returned) for the same data.
 */
public void cancel() {
 timer.cancel();
 unload();
}

代码示例来源:origin: org.jboss.errai/errai-bus

private void notifyConnected() {
 pingTimeout.cancel();
 retries = 0;
 if (!connected) {
  connected = true;
  connectedTime = System.currentTimeMillis();
  logger.info(this + ": SSE channel is active.");
 }
 if (clientMessageBus.getState() == BusState.CONNECTION_INTERRUPTED) {
  clientMessageBus.setState(BusState.CONNECTED);
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

private void onFailure(Throwable ex) {
 timer.cancel();
 try {
  if (callback != null) {
   callback.onFailure(ex);
  }
 } finally {
  unload();
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

private void onSuccess(T data) {
 timer.cancel();
 try {
  if (callback != null) {
   callback.onSuccess(data);
  }
 } finally {
  unload();
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

void fireOnResponseReceived(RequestCallback callback) {
 if (xmlHttpRequest == null) {
  // the request has timed out at this point
  return;
 }
 timer.cancel();
 /*
  * We cannot use cancel here because it would clear the contents of the
  * JavaScript XmlHttpRequest object so we manually null out our reference to
  * the JavaScriptObject
  */
 final XMLHttpRequest xhr = xmlHttpRequest;
 xmlHttpRequest = null;
 Response response = createResponse(xhr);
 callback.onResponseReceived(this, response);
}

代码示例来源:origin: org.jboss.errai/errai-bus

@Override
public Collection<Message> stop(final boolean stopAllCurrentRequests) {
 receiveCommCallback.cancel();
 throttleTimer.cancel();
 
 try {
  if (stopAllCurrentRequests) {
   // Now stop all the in-flight XHRs
   for (final RxInfo r : pendingRequests) {
    r.getRequest().cancel();
   }
   pendingRequests.clear();
   return new ArrayList<Message>(undeliveredMessages);
  }
  else {
   return Collections.emptyList();
  }
 }
 finally {
  undeliveredMessages.clear();
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Schedules a timer to elapse in the future. If the timer is already running then it will be
 * first canceled before re-scheduling.
 *
 * @param delayMillis how long to wait before the timer elapses, in milliseconds
 */
public void schedule(int delayMillis) {
 if (delayMillis < 0) {
  throw new IllegalArgumentException("must be non-negative");
 }
 if (isRunning()) {
  cancel();
 }
 isRepeating = false;
 timerId = setTimeout(createCallback(this, cancelCounter), delayMillis);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Schedules a timer that elapses repeatedly. If the timer is already running then it will be
 * first canceled before re-scheduling.
 *
 * @param periodMillis how long to wait before the timer elapses, in milliseconds, between each
 *        repetition
 */
public void scheduleRepeating(int periodMillis) {
 if (periodMillis <= 0) {
  throw new IllegalArgumentException("must be positive");
 }
 if (isRunning()) {
  cancel();
 }
 isRepeating = true;
 timerId = setInterval(createCallback(this, cancelCounter), periodMillis);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Cancels a pending request. If the request has already been canceled or if
 * it has timed out no action is taken.
 */
public void cancel() {
 if (xmlHttpRequest == null) {
  return;
 }
 timer.cancel();
 /*
  * There is a strange race condition that occurs on Mozilla when you cancel
  * a request while the response is coming in. It appears that in some cases
  * the onreadystatechange handler is still called after the handler function
  * has been deleted and during the call to XmlHttpRequest.abort(). So we
  * null the xmlHttpRequest here and that will prevent the
  * fireOnResponseReceived method from calling the callback function.
  * 
  * Setting the onreadystatechange handler to null gives us the correct
  * behavior in Mozilla but crashes IE. That is why we have chosen to fixed
  * this in Java by nulling out our reference to the XmlHttpRequest object.
  */
 final XMLHttpRequest xhr = xmlHttpRequest;
 xmlHttpRequest = null;
 xhr.clearOnReadyStateChange();
 xhr.abort();
}

代码示例来源:origin: org.jboss.errai/errai-bus

private void stop(final boolean sendDisconnect, final TransportError reason) {
 logger.info("stopping bus ...");
 if (initialConnectTimer != null) {
  initialConnectTimer.cancel();
 }
 if (degradeToUnitialized()) {
  setState(BusState.UNINITIALIZED);
  deferredMessages.clear();
  remotes.clear();
  deferredSubscriptions.clear();
 }
 else if (state != BusState.LOCAL_ONLY) {
  setState(BusState.LOCAL_ONLY, reason);
 }
 // Optionally tell the server we're going away (this causes two POST requests)
 if (sendDisconnect && isRemoteCommunicationEnabled()) {
  encodeAndTransmit(CommandMessage.create()
    .toSubject(BuiltInServices.ServerBus.name()).command(BusCommand.Disconnect)
    .set(MessageParts.PriorityProcessing, "1"));
 }
 deferredMessages.addAll(transportHandler.stop(true));
}

代码示例来源:origin: org.jboss.errai/errai-bus

/**
 * Sends a ping request to the server. If the ping response is not received
 * within a reasonable time limit, notifyDisconnected() will be called.
 */
private void verifyConnected() {
 // in case we were in the middle of something already
 pingTimeout.cancel();
 
 transmit(Collections.singletonList(MessageBuilder.createMessage()
   .toSubject("ServerEchoService")
   .signalling().done().repliesToSubject(SSE_AGENT_SERVICE).getMessage()));
 pingTimeout.schedule(2500);
}

代码示例来源:origin: org.jboss.errai/errai-bus

private void notifyDisconnected() {
 connected = false;
 pingTimeout.cancel();
 logger.info(this + " channel disconnected.");
 connectedTime = -1;
 clientMessageBus.setState(BusState.CONNECTION_INTERRUPTED);
 disconnect(sseChannel);
 if (!stopped) {
  if (retries == 0) {
   transmit(Collections.singletonList(MessageBuilder.createMessage()
      .toSubject("ServerEchoService")
      .signalling().done().repliesToSubject(SSE_AGENT_SERVICE).getMessage()));
  }
  
  final int retryDelay = Math.min((retries * 1000) + 1, 10000);
  logger.info("attempting SSE reconnection in " + retryDelay + "ms -- attempt: " + (++retries));
  
  new Timer() {
   @Override
   public void run() {
    if (!stopped) {
     start();
    }
   }
  }.schedule(retryDelay);
 }
}

代码示例来源:origin: org.jboss.errai/errai-bus

rxRetries++;
throttleTimer.cancel();
new Timer() {
 @Override

代码示例来源:origin: org.jboss.errai/errai-bus

txRetries++;
throttleTimer.cancel();
new Timer() {
 @Override

代码示例来源:origin: com.google.gwt/gwt-servlet

cancellationTimer.cancel();

代码示例来源:origin: com.google.gwt/gwt-servlet

showTimer.cancel();
showTimer = null;
onComplete();

相关文章