当前位置: 首页>>代码示例>>C#>>正文


C# Task.All方法代码示例

本文整理汇总了C#中System.Threading.Tasks.Task.All方法的典型用法代码示例。如果您正苦于以下问题:C# Task.All方法的具体用法?C# Task.All怎么用?C# Task.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.Tasks.Task的用法示例。


在下文中一共展示了Task.All方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateLockFile

        private bool UpdateLockFile(PublishRoot root)
        {
            var appEnv = (IApplicationEnvironment)root.HostServices.GetService(typeof(IApplicationEnvironment));

            var feedOptions = new FeedOptions();
            feedOptions.IgnoreFailedSources = true;
            feedOptions.Sources.Add(root.TargetPackagesPath);
            feedOptions.TargetPackagesFolder = root.TargetPackagesPath;

            var tasks = new Task<bool>[root.Projects.Count];
            for (int i = 0; i < root.Projects.Count; i++)
            {
                var project = root.Projects[i];
                var restoreCommand = new RestoreCommand(appEnv);

                foreach (var runtime in root.Runtimes)
                {
                    restoreCommand.TargetFrameworks.Add(project.SelectFrameworkForRuntime(runtime));
                }

                var restoreDirectory = project.IsPackage ? Path.Combine(project.TargetPath, "root") : project.TargetPath;
                restoreCommand.SkipRestoreEvents = true;
                restoreCommand.SkipInstall = true;
                // This is a workaround for #1322. Since we use restore to generate the lock file
                // after publish, it's possible to fail restore after copying the closure
                // if framework assemblies and packages have the same name. This is more likely now
                // since dependencies may exist in the top level
                restoreCommand.IgnoreMissingDependencies = true;
                restoreCommand.CheckHashFile = false;
                restoreCommand.RestoreDirectories.Add(restoreDirectory);
                restoreCommand.FeedOptions = feedOptions;
                restoreCommand.Reports = root.Reports.ShallowCopy();

                // Mute "dnu restore" completely if it is invoked by "dnu publish --quiet"
                restoreCommand.Reports.Information = root.Reports.Quiet;

                tasks[i] = restoreCommand.Execute();
            }

            Task.WaitAll(tasks);

            return tasks.All(t => t.Result);
        }
开发者ID:noahfalk,项目名称:dnx,代码行数:43,代码来源:PublishProject.cs

示例2: UpdateLockFile

        private bool UpdateLockFile(PublishRoot root)
        {
            var tasks = new Task<bool>[root.Projects.Count];
            for (int i = 0; i < root.Projects.Count; i++)
            {
                var project = root.Projects[i];
                var restoreDirectory = project.IsPackage ? Path.Combine(project.TargetPath, "root") : project.TargetPath;
                tasks[i] = Restore(root, project, restoreDirectory);
            }

            Task.WaitAll(tasks);

            return tasks.All(t => t.Result);
        }
开发者ID:rajeevkb,项目名称:dnx,代码行数:14,代码来源:PublishProject.cs

示例3: FinalWork

        private void FinalWork(Task[] tasks)
        {
            if (tasks.All(t => t.Status == TaskStatus.RanToCompletion))
            {
                Logger.LogToFile("======== Create PNR process ended at :" + DateTime.Now.ToString());

                this.progressBar.BeginInvoke((MethodInvoker)delegate()
                {
                    btnCreate.Enabled = true;
                    btnProcessPNRs.Enabled = true;
                    progressBar.Visible = false;
                    progressBar.Refresh();
                    lblInfo.Text = "PROCESS COMPLETED";
                    lblInfo.Refresh();
                    lblInfo.ForeColor = Color.Green;
                    lblUploadInfo.Text = string.Empty;
                });

            }
        }
开发者ID:nikunj-mochi,项目名称:flydubai-Bookings-generator,代码行数:20,代码来源:FrmCreatePNRs.cs


注:本文中的System.Threading.Tasks.Task.All方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。