コード例 #1
0
        async Task DownloadProject(CancellationToken token, ReflectClient reflectClient)
        {
            m_CurrentCount = 0;
            m_TotalCount   = 0;
            var manifests = await reflectClient.GetSyncManifestsAsync();

            m_TotalCount = manifests.Sum(e => e.Content.Count);

            var currentTasks = new List <Task>();

            foreach (var manifest in manifests)
            {
                foreach (var content in manifest.Content)
                {
                    token.ThrowIfCancellationRequested();
                    var streamKey = new StreamKey(manifest.SourceId, content.Key);
                    currentTasks.Add(reflectClient.DownloadSyncModelAsync(streamKey, content.Value.Hash));
                    if (currentTasks.Count < m_Settings.maxTaskSize)
                    {
                        continue;
                    }

                    var completedTask = await Task.WhenAny(currentTasks);

                    currentTasks.Remove(completedTask);
                    m_CurrentCount++;
                }
            }

            while (currentTasks.Count < 0)
            {
                token.ThrowIfCancellationRequested();
                var completedTask = await Task.WhenAny(currentTasks);

                currentTasks.Remove(completedTask);
                m_CurrentCount++;
            }
        }
コード例 #2
0
 public override void Run()
 {
     m_Time   = DateTime.Now;
     m_Client = new ReflectClient(m_UpdateDelegate, m_User, m_PlayerStorage, m_Settings.downloadProject);
     base.Run();
 }