void CheckCondition() { lock (downloadDone) { foreach (var str in downloadDone) { ResMng.AddDownloadDoneRes(str); } downloadDone.Clear(); } if (checkList.Count != 0) { Debug.Log("add"); } if (checkList.Count != 0) { HttpClient.Condition del = null; List <ReferenceNode> download = null; lock (checkList) { foreach (var check in checkList) { ReferenceNode root = ReferenceNode.GetExistNode(check.root.strResources); if (root != null) { ResMng.CollectDownloadRes(check.root.strResources, ref download, ref root); if (download.Count == 0) { Log.LogInfo("download.count == 0 can load res"); del = check; } else { Log.LogInfo("load " + check.strResource + "need extra res" + download.Count); } } else { del = check; break; } } if (del != null) { Log.LogInfo("remove condition:" + del + "resource" + del.strResource); checkList.Remove(del); if (download != null && download.Count == 0) { Log.LogInfo("call callback to load resources" + del.strResource); del.cb(del.param); } } } } }
public static void AddCheck(List <HttpClient.Condition> call) { lock (checkList) { foreach (var each in call) { bool bExist = false; HttpClient.Condition del = null; foreach (var exist in checkList) { if (exist.strResource == each.strResource) { bExist = true; del = exist; break; } } if (!bExist) { checkList.Add(each); } else { try { if (del != null) { checkList.Remove(del); } checkList.Add(each); } catch { Log.LogInfo("error"); } } } } }