本文整理汇总了C#中ConcurrentBag.ToQueryResult方法的典型用法代码示例。如果您正苦于以下问题:C# ConcurrentBag.ToQueryResult方法的具体用法?C# ConcurrentBag.ToQueryResult怎么用?C# ConcurrentBag.ToQueryResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConcurrentBag
的用法示例。
在下文中一共展示了ConcurrentBag.ToQueryResult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Console.WriteLine("program start!!");
// ClinetsInfoParser.Parse();
var tbl=new DataTable();
tbl.TableName = "custom";
tbl.Columns.Add("Name");
tbl.Columns.Add("Producer");
tbl.Columns.Add("Trash");
tbl.Columns.Add("Expires");
tbl.Columns.Add("Quantity");
tbl.Columns.Add("Trash2");
tbl.Columns.Add("Division");
for (int i = 0; i < 15; i++)
tbl.Rows.Add("Name" + i.ToString(), "Producer" + i.ToString(), i.ToString(), DateTime.Now.ToShortDateString(),
i.ToString(),i.ToString(), "Division" + i.ToString());
var stream=new MemoryStream();
tbl.WriteXml(stream,XmlWriteMode.WriteSchema);
var data= Packer.Pack(stream);
var result = new ConcurrentBag<byte[]>();
result.Add(data);
result.ToQueryResult();
Console.ReadKey();
}
示例2: QueryClassesManager
List<QueryResult> IRISIQueryContract.PostQuery(QueryData data)
{
var result = new ConcurrentBag<byte[]>();
// new List<byte[]>();
var queryClassesManager = new QueryClassesManager();
var factory = new QueryClassesFactory();
try
{
queryClassesManager.LoadQueryClasses();
}
catch (Exception exp)
{
logger.Warn("queryClassesManager, failed \r\n"+exp.ToString());
throw new FaultException("queryClassesManager, failed");
}
var queryClasses = queryClassesManager.Repo.QueryClasses;
Parallel.ForEach(queryClasses, currentClass =>
{
try
{
var instance = factory.Create(currentClass);
result.Add(instance.ExecuteQuery(data));
}
catch (FaultException faultEx)
{
logger.Warn("failed on executing query \r\n" + faultEx.ToString());
}
catch (Exception exp)
{
logger.Warn("failed creating IDataBase instance \r\n" + exp.ToString());
}
});
List<QueryResult> re=null;
try
{
re = result.ToQueryResult();
}
catch (Exception exp)
{
logger.Warn("failed creating results list \r\n" + exp.ToString());
throw new FaultException("failed creating results list");
}
return re;
}