From: Ian Jackson Date: Sun, 5 Sep 2010 12:28:19 +0000 (+0100) Subject: fetch yarrg timestamp asynchronously X-Git-Tag: 0.9.9~12 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=jarrg-ian.git;a=commitdiff_plain;h=ab0647726ea33606a5864f7f17e13c8e6fbb33b0 fetch yarrg timestamp asynchronously --- 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;