From ab0647726ea33606a5864f7f17e13c8e6fbb33b0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 5 Sep 2010 13:28:19 +0100 Subject: [PATCH] fetch yarrg timestamp asynchronously --- .../tedpearson/ypp/market/MarketUploader.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/com/tedpearson/ypp/market/MarketUploader.java b/src/com/tedpearson/ypp/market/MarketUploader.java index b3fa49f..bac5522 100644 --- a/src/com/tedpearson/ypp/market/MarketUploader.java +++ b/src/com/tedpearson/ypp/market/MarketUploader.java @@ -409,19 +409,31 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis * * @exception Exception if an error we didn't expect occured */ + private class YarrgTimestampFetcher extends Thread { + public String ts = null; + public void run() { + try { + ts = getYarrgTimestamp(); + progresslog("(async) yarrg timestamp ready."); + } catch(Exception e) { + error("Error getting YARRG timestamp: "+e); + } + } + }; + private void runUpload() throws Exception { progresslog("starting"); - String yarrgts = ""; ProgressMonitor pm = new ProgressMonitor(frame,"Processing Market Data","Getting table data",0,100); pm.setMillisToDecideToPopup(0); pm.setMillisToPopup(0); boolean doneyarrg = false, donepctb = false; + YarrgTimestampFetcher yarrgts_thread = null; if (uploadToYarrg) { - progresslog("yarrg timestamp..."); - yarrgts = getYarrgTimestamp(); - progresslog("yarrg timestamp done."); + progresslog("(async) yarrg timestamp..."); + yarrgts_thread = new YarrgTimestampFetcher(); + yarrgts_thread.start(); } AccessibleTable accesstable = findMarketTable(); @@ -449,6 +461,14 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis } progresslog("(async) getisland done"); + String yarrgts = null; + if (yarrgts_thread != null) { + progresslog("(async) yarrg timestamp join..."); + yarrgts_thread.join(); + progresslog("(async) yarrg timestamp joined."); + yarrgts = yarrgts_thread.ts; + } + if (islandName == null) { error("Could not find island name in YPP user interface."); return; -- 2.30.2