我正在尝试制作一个progressBar,它将以0.1步为单位设置其进度,延迟时间为1000毫秒,直到它“满”为止。
我已经找到了一个解决方法,如何延迟一步,但是无法将其转换为for循环,将以0.1步为单位设置进度,直到进度等于1,因此已满。
我如何修改下面的解决方案来实现这一目标?
<Error>: -[NETAWDManager reportStats:metricID:] AWDServerConnection newMetricContainerWithIdentifier failed for metric 2686983, server 0x16d62570, not reporting:
<AWDLibnetcoreTCPConnectionReport: 0x16e418a0> {
cellularFallbackReport = {
dataUsageSnapshotsAtNetworkEvents = (
{
bytesIn = 1999999;
bytesOut = 1600;
}
);
"fallbackTimer_msecs" = 0;
fellback = 0;
networkEvents = (
"NETWORK_EVENT_DATA_STALL_AT_APP_LAYER"
);
"timeToNetworkEvents_msecs" = (
5168
);
};
clientIdentifier = "com.apple.WebKit.Networking";
connectionStatisticsReport = {
DNSAnswersCached = 0;
"DNSResolvedTime_msecs" = 0;
RTTvariance = 0;
"appDataStallTimer_msecs" = 3;
appReportingDataStallCount = 1;
"bestRTT_msecs" = 0;
betterRouteEventCount = 0;
bytesDuplicate = 0;
bytesIn = 2700000;
bytesOut = 3800;
bytesOutOfOrder = 0;
bytesRetransmitted = 0;
cellularFallback = 0;
cellularRRCConnected = 0;
connected = 1;
connectedInterfaceType = "(unknown: 4)";
"connectionEstablishmentTime_msecs" = 1;
connectionReuseCount = 0;
"currentRTT_msecs" = 0;
"flowDuration_msecs" = 40208;
interfaceType = "(unknown: 4)";
kernelReportedStalls = 0;
kernelReportingConnectionStalled = 0;
kernelReportingReadStalled = 0;
kernelReportingWriteStalled = 0;
packetsDuplicate = 0;
packetsIn = 210;
packetsOut = 9;
packetsOutOfOrder = 0;
packetsRetransmitted = 0;
"smoothedRTT_msecs" = 0;
synRetransmissionCount = 0;
tcpFastOpen = 0;
"timeToConnectionEstablishment_msecs" = 2;
"timeToConnectionStart_msecs" = 1;
"timeToDNSResolved_msecs" = 0;
"timeToDNSStart_msecs" = 0;
trafficClass = 0;
};
delegated = 1;
reportReason = "REPORT_REASON_DATA_STALL_AT_APP_LAYER";
sourceAppIdentifier = "com.supermemo.sm-com";
}
Jul 6 10:13:59 iPad-xxx assistantd[268] <Error>: tcp_connection_tls_session_error_callback_imp 7 __tcp_connection_tls_session_callback_write_block_invoke.434 error 22
Jul 6 10:13:59 iPad-xxx assistantd[268] <Error>: NSURLSessionStreamTask: TCPConnection read invalidated by closed connection
Jul 6 10:13:59 iPad-xxx networkd[87] <Error>: -[NETAWDManager reportStats:metricID:] AWDServerConnection newMetricContainerWithIdentifier failed for metric 2686980, server 0x16d62570, not reporting:
<AWDMPTCPConnectionReport: 0x16d3ab50> {
"client_id" = assistantd;
"establishment_cellular_fallback" = 0;
"establishment_failure_error" = 0;
"establishment_forced_tcp_fallback" = 0;
"establishment_interface_name" = en0;
"establishment_success" = 1;
"establishment_syn_retransmits" = 0;
"establishment_tcp_fallback" = 0;
"establishment_time" = "0.0573505";
"interface_reports" = (
{
"data_in_KB" = 5;
"data_out_KB" = 2;
"interface_name" = en0;
"post_connect_subflow_failure_errors" = (
);
"post_connect_tcp_fallback_count" = 0;
"secondary_flow_failure_count" = 0;
"secondary_flow_success_count" = 0;
}
);
"post_connect_multi_homed" = 1;
"post_connect_session_lifetime" = "42.711159041";
"post_connect_single_homed" = 0;
"post_connect_subflow_attempt_count" = 2;
"post_connect_subflow_max_subflow_count" = 1;
"subflow_switching_count" = 0;
}
答案 0 :(得分:0)
让你的任务执行迭代,并按原样更新它的进度:
Task<Void> sleeper = new Task<Void>() {
@Override
protected Void call() throws Exception {
final int numIterations = 10 ;
for (int i = 0 ; i < numIterations ; i++) {
updateProgress(i, numIterations);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
updateProgress(numIterations, numIterations);
return null;
}
};
然后将进度条的进度绑定到任务的进度:
progressBar.progressProperty().bind(sleeper.progressProperty());