Esempio n. 1
0
    /// <summary>
    /// 检查等待下载队列,开始下载,并行下载数应不大于平台CPU线程数
    /// </summary>
    /// <returns></returns>
    IEnumerator DownloadFiles()
    {
        while (true)
        {
            if (waitingTasks.Count != 0)
            {
                if (downloadingTasks.Count < SystemInfo.processorCount)
                {
                    DownloadTask dTask = waitingTasks.Dequeue();
                    dTask.ExecuteTask();
                    Debug.Log("start download file:" + dTask.LocalSaveName);
                    downloadingTasks.Add(dTask.LocalSaveName, dTask);
                }
            }
            else
            {
                if (downloadingTasks.Count == 0)
                {
                    if (newVersionString != null)
                    {
                        PlayerPrefs.SetString("version", newVersionString);
                    }

                    UpdateFileListFile();
                    ActionAfterUpdateCompleted();

                    StopCoroutine(DownloadFiles());
                }
            }
            yield return(new WaitForEndOfFrame());
        }
    }