本文整理汇总了C#中CIAPI.Rpc.Client.EndGetPriceBars方法的典型用法代码示例。如果您正苦于以下问题:C# Client.EndGetPriceBars方法的具体用法?C# Client.EndGetPriceBars怎么用?C# Client.EndGetPriceBars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIAPI.Rpc.Client
的用法示例。
在下文中一共展示了Client.EndGetPriceBars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
} //close lambda expression
); //close method invocation
break;
case 2:
// - Price bars via task method...
Console.WriteLine("Begin Sync task...");
Thread.Sleep(1000);
Task<Dictionary<String, PriceBarDTO[]>> taskWithFactoryAndState =
Task.Factory.StartNew<Dictionary<String, PriceBarDTO[]>>((stateObj) =>
{
Dictionary<String, PriceBarDTO[]> pricetasks = new Dictionary<String, PriceBarDTO[]>();
for (int i = 0; i < (int)stateObj; i++)
{
GetPriceBarResponseDTO priceBars = _ctx.GetPriceBars(markets[i], interval, 1, no);
Console.WriteLine("Received bar from task sync call:" + markets[i]);
priceBarResults.Add(markets[i], priceBars.PriceBars);
}
return pricetasks;
}, 10);
gate = new AutoResetEvent(false);
try
{
Task.WaitAll(taskWithFactoryAndState);
gate.Set();
}
catch (AggregateException aggEx)
{
gate.Set();
foreach (Exception ex in aggEx.InnerExceptions)
{
Console.WriteLine(string.Format("Caught exception '{0}'",
ex.Message));
}
}
gate.WaitOne();
break;
}
foreach (String market in markets)
{
Console.WriteLine("Begin async call:" + market);
_ctx.BeginGetPriceBars(market,interval,1,no, pricebarResult =>
{
Console.WriteLine("Received bar from async call:" + market);
GetPriceBarResponseDTO pricebar = _ctx.EndGetPriceBars(pricebarResult);
priceBarResultsASync.Add(market, pricebar.PriceBars);
}, null);
}
while (count <= timeout)
{
Thread.Sleep(1000);
count++;
if (priceBarResults.Count == priceBarResultsASync.Count) break;
Console.WriteLine("Waiting for async... " + count + " seconds elapsed.");
}
if (priceBarResults.Count == priceBarResultsASync.Count)
{
Console.WriteLine("Sync and Async calls completed now checking...");
foreach (KeyValuePair<String, PriceBarDTO[]> KeyPairSync in priceBarResults)
{
String marketid = KeyPairSync.Key;
PriceBarDTO[] priceBarSync = KeyPairSync.Value;
PriceBarDTO[] priceBarAsync = priceBarResultsASync[marketid];
for (int i = 0; i < priceBarSync.Count(); i++)
{
// Lambda expression as executable code.
//Func<int, bool> deleg = i => i < 5;
Func<Decimal, Decimal, bool> myFunc = (x, y) => x == y;
bool result = myFunc(priceBarSync[i].Close, priceBarAsync[i].Close);
if (!result)
{
Console.WriteLine("Sync and Async mismatch: Sync: " + priceBarSync[i].Close + " Async: " + priceBarAsync[i].Close);
errors++;
}
}
}
Console.WriteLine("Sync and Async match test completed... There were: " + errors + " errors.");
errorList.Add(errors);
Thread.Sleep(2000);
} else if(priceBarResults.Count != priceBarResultsASync.Count)
{
Console.WriteLine("Sync and Async match test completed... We timed out after " + count + " seconds.. Sync count: " + priceBarResults.Count + " Async count: " + priceBarResultsASync.Count);
errorList.Add(9999);
}
}
}
Console.WriteLine("**** ERRORS ***");
foreach (int error in errorList)
{
Console.Write(error + ",");
}
Console.WriteLine("**** END ERRORS ***");
//String stop = Console.ReadLine();
}