本文整理汇总了C#中Array.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Array.ToArray方法的具体用法?C# Array.ToArray怎么用?C# Array.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array.ToArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
Run()
{
Log.Detail("Running build");
// TODO: should the rank collections be sorted, so that modules with fewest dependencies are first?
var graph = Graph.Instance;
var metaDataType = graph.BuildModeMetaData.GetType();
var useEvaluation = CheckIfModulesNeedRebuilding(metaDataType);
var explainRebuild = CommandLineProcessor.Evaluate(new Options.ExplainBuildReason());
var immediateOutput = CommandLineProcessor.Evaluate(new Options.ImmediateOutput());
ExecutePreBuild(metaDataType);
if (!System.IO.Directory.Exists(graph.BuildRoot))
{
System.IO.Directory.CreateDirectory(graph.BuildRoot);
}
var threadCount = CommandLineProcessor.Evaluate(new Options.MultiThreaded());
if (0 == threadCount)
{
threadCount = System.Environment.ProcessorCount;
}
System.Exception abortException = null;
if (threadCount > 1)
{
var cancellationSource = new System.Threading.CancellationTokenSource();
var cancellationToken = cancellationSource.Token;
// LongRunning is absolutely necessary in order to achieve paralleism
var creationOpts = System.Threading.Tasks.TaskCreationOptions.LongRunning;
var continuationOpts = System.Threading.Tasks.TaskContinuationOptions.LongRunning;
var scheduler = new LimitedConcurrencyLevelTaskScheduler(threadCount);
var factory = new System.Threading.Tasks.TaskFactory(
cancellationToken,
creationOpts,
continuationOpts,
scheduler);
var tasks = new Array<System.Threading.Tasks.Task>();
foreach (var rank in graph.Reverse())
{
foreach (var module in rank)
{
var context = new ExecutionContext(useEvaluation, explainRebuild, immediateOutput);
var task = factory.StartNew(() =>
{
if (cancellationToken.IsCancellationRequested)
{
return;
}
var depTasks = new Array<System.Threading.Tasks.Task>();
foreach (var dep in module.Dependents)
{
if (null == dep.ExecutionTask)
{
continue;
}
depTasks.Add(dep.ExecutionTask);
}
foreach (var dep in module.Requirements)
{
if (null == dep.ExecutionTask)
{
continue;
}
depTasks.Add(dep.ExecutionTask);
}
System.Threading.Tasks.Task.WaitAll(depTasks.ToArray());
if (cancellationToken.IsCancellationRequested)
{
return;
}
try
{
(module as IModuleExecution).Execute(context);
}
catch (Exception ex)
{
abortException = ex;
cancellationSource.Cancel();
}
finally
{
if (context.OutputStringBuilder != null && context.OutputStringBuilder.Length > 0)
{
Log.Info(context.OutputStringBuilder.ToString());
}
if (context.ErrorStringBuilder != null && context.ErrorStringBuilder.Length > 0)
{
Log.Info(context.ErrorStringBuilder.ToString());
}
}
});
tasks.Add(task);
//.........这里部分代码省略.........