本文整理汇总了C#中ConcurrentBag.ElementAt方法的典型用法代码示例。如果您正苦于以下问题:C# ConcurrentBag.ElementAt方法的具体用法?C# ConcurrentBag.ElementAt怎么用?C# ConcurrentBag.ElementAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConcurrentBag
的用法示例。
在下文中一共展示了ConcurrentBag.ElementAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: rightDRAWING
/// <summary>
/// Сшивка снимков правого глаза
/// </summary>
private void rightDRAWING()
{
List<Int32> x = new List<Int32>(7);
List<Int32> y = new List<Int32>(7);
Int32 iPoint_number;
//Double x1 = 850, y1 = 750;
//Расставляем снимки по схеме
x.Add(1050); y.Add(1150); //1
x.Add(1050); y.Add(600); //2
x.Add(550); y.Add(700); //3
x.Add(450); y.Add(1150); //4
x.Add(550); y.Add(1600); //5
x.Add(1050); y.Add(1700); //6
x.Add(1550); y.Add(1600); //7
x.Add(1650); y.Add(1150); //8
x.Add(1550); y.Add(700); //9
Int32 check = 0;
//Сомещаем, если есть общие ключевые точки
//-Для первых трех снимков
for (Int32 i = 0; i < 3; i++)
{
iPointPairs = CreatePairs(iPoints_right[i], iPoints_right[i + 1]);
iPoint_number = bestIPoint_idSearch();
if (iPoint_number != -1)
{
Double x1 = iPointPairs.ElementAt(iPoint_number).p1.x - iPointPairs.ElementAt(iPoint_number).p2.x;
Double y1 = iPointPairs.ElementAt(iPoint_number).p1.y - iPointPairs.ElementAt(iPoint_number).p2.y;
x[i + 1] = Convert.ToInt32(x[i] + x1);
y[i + 1] = Convert.ToInt32(y[i] + y1);
check++;
}
}
//-Для 4го и 5го снимков
for (Int32 i = 3; i < 5; i++)
{
iPointPairs = CreatePairs(iPoints_right[1], iPoints_right[i]);
iPoint_number = bestIPoint_idSearch();
if (iPoint_number != -1)
{
Double x1 = iPointPairs.ElementAt(iPoint_number).p1.x - iPointPairs.ElementAt(iPoint_number).p2.x;
Double y1 = iPointPairs.ElementAt(iPoint_number).p1.y - iPointPairs.ElementAt(iPoint_number).p2.y;
x[i] = Convert.ToInt32(x[1] + x1);
y[i] = Convert.ToInt32(y[1] + y1);
check++;
}
}
//-Для 6го и 7го снимков
for (Int32 i = 5; i < 7; i++)
{
iPointPairs = CreatePairs(iPoints_right[0], iPoints_right[i]);
iPoint_number = bestIPoint_idSearch();
if (iPoint_number != -1)
{
Double x1 = iPointPairs.ElementAt(iPoint_number).p1.x - iPointPairs.ElementAt(iPoint_number).p2.x;
Double y1 = iPointPairs.ElementAt(iPoint_number).p1.y - iPointPairs.ElementAt(iPoint_number).p2.y;
x[i] = Convert.ToInt32(x[0] + x1);
y[i] = Convert.ToInt32(y[0] + y1);
check++;
}
}
MessageBox.Show((9-check).ToString() + " снимков из 9 будут расположены по предустановленным координатам", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
Bitmap img = new Bitmap(5000, 4500);
Graphics g = Graphics.FromImage(img);
Rectangle rect = new Rectangle(0, 0, img.Width, img.Height);
SolidBrush blck = new SolidBrush(Color.Black);
Region fill = new Region(rect);
g.FillRegion(blck, fill);
/*
for (Int32 i = x.Count - 1; i >= 0; i--)
g.DrawImage(eyeImages_right[i], new Point(x[i], y[i]));
*/
for (Int32 i = x.Count - 1; i >= 0; i--)
if (i == 8 || i == 6 || i == 4 || i == 2) g.DrawImage(eyeImages_right[i], new Point(x[i], y[i]));
for (Int32 i = x.Count - 1; i >= 0; i--)
if (i == 7 || i == 5 || i == 3 || i == 1 || i == 0) g.DrawImage(eyeImages_right[i], new Point(x[i], y[i]));
pictureImage.Image = img;
eyeImages_right.Add(img);
//.........这里部分代码省略.........
示例2: MultiThreadedCompile
static bool MultiThreadedCompile(int maxParallelism, string workingDirectory, List<string> toCompile, bool overwrite, bool warnAsErrors, bool minify, bool verbose, string spriteProg, string spriteArguments, bool autoCacheBreak, bool autoPrefix, out DependencyGraph dependencies)
{
var @lock = new Semaphore(0, toCompile.Count);
var contexts = new ConcurrentBag<Context>();
var outMsg = new ConcurrentBag<string>();
toCompile.AsParallel()
.WithDegreeOfParallelism(maxParallelism)
.WithExecutionMode(ParallelExecutionMode.ForceParallelism)
.ForAll(
delegate(string compile)
{
try
{
var threadContext = new Context(FileCache);
contexts.Add(threadContext);
var buffer = new StringBuilder();
var outputFile = OutputFileFor(compile, overwrite: overwrite);
buffer.AppendLine("\t" + compile);
buffer.Append("\tto " + outputFile);
var timer = new Stopwatch();
timer.Start();
var result = Compile(workingDirectory, compile, outputFile, threadContext, minify, warnAsErrors, autoCacheBreak, autoPrefix);
timer.Stop();
if (result)
{
buffer.AppendLine(" in " + timer.ElapsedMilliseconds + "ms");
}
else
{
buffer.AppendLine(" failed after " + timer.ElapsedMilliseconds + "ms");
}
outMsg.Add(buffer.ToString());
}
finally
{
@lock.Release();
}
}
);
for (int i = 0; i < toCompile.Count; i++)
@lock.WaitOne();
var mergedContext = contexts.ElementAt(0);
for (int i = 1; i < contexts.Count; i++)
{
mergedContext = mergedContext.Merge(contexts.ElementAt(i));
}
dependencies = mergedContext.Dependecies;
var infoMessages = mergedContext.GetInfoMessages().ToList();
var errors = mergedContext.GetErrors();
if (spriteProg.HasValue())
{
foreach (var sprite in mergedContext.GetSpriteFiles())
{
var commandErrors = RunSpriteCommand(spriteProg, workingDirectory, sprite, spriteArguments, infoMessages);
errors = errors.SelectMany(s => s.ToList()).Union(commandErrors).ToLookup(k => k.Type);
}
}
if (verbose)
{
foreach (var msg in outMsg)
{
Console.Write(msg);
}
if (outMsg.Count > 0) Console.WriteLine();
}
if (errors.Count > 0)
{
var parseErrors = errors.Where(e => e.Key == ErrorType.Parser).SelectMany(s => s.ToList()).Distinct().ToList();
var compileErrors = errors.Where(e => e.Key == ErrorType.Compiler).SelectMany(s => s.ToList()).Distinct().ToList();
Print("Errors", parseErrors, compileErrors);
}
if (mergedContext.GetWarnings().Count > 0)
{
var parseWarnings = mergedContext.GetWarnings().Where(e => e.Key == ErrorType.Parser).SelectMany(s => s.ToList()).Distinct().ToList();
var compileWarnings = mergedContext.GetWarnings().Where(e => e.Key == ErrorType.Compiler).SelectMany(s => s.ToList()).Distinct().ToList();
Print("Warnings", parseWarnings, compileWarnings);
}
if (verbose && infoMessages.Count > 0)
{
//.........这里部分代码省略.........