private void PollDownloadContent( string inputJson, string downloadPath, string localPath, string overrides, bool reload, string cacheKey ) { var queueName = "Download" + cacheKey; // Get queue lock var queueLock = StringCache.getCache(queueName); var downloaded = false; var inputData = new Inputs().FromJson(inputJson); if (reload) { StringCache.setCache(InstanceGuid.ToString(), ""); } if (queueLock != "true" && inputData.Task != null) { StringCache.setCache(queueName, "true"); StringCache.setCache(cacheKey, null); QueueManager.addToQueue(queueName, () => { try { while (!downloaded) { StringCache.setCache(cacheKey + "progress", "Downloading..."); ExpireSolutionThreadSafe(true); downloaded = DownloadContent.Download(inputJson, downloadPath, localPath, overrides); StringCache.setCache(cacheKey, downloaded.ToString()); if (!downloaded) { StringCache.setCache(cacheKey + "progress", "Waiting for results..."); ExpireSolutionThreadSafe(true); Thread.Sleep(60000); } else { StringCache.setCache(cacheKey + "progress", "Downloaded files"); } ExpireSolutionThreadSafe(true); } } catch (Exception e) { StringCache.setCache(InstanceGuid.ToString(), e.Message); StringCache.setCache(cacheKey, "error"); } ExpireSolutionThreadSafe(true); Thread.Sleep(2000); StringCache.setCache(queueName, ""); }); } }