本文整理汇总了C#中CommandProcessorContext.Completed方法的典型用法代码示例。如果您正苦于以下问题:C# CommandProcessorContext.Completed方法的具体用法?C# CommandProcessorContext.Completed怎么用?C# CommandProcessorContext.Completed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandProcessorContext
的用法示例。
在下文中一共展示了CommandProcessorContext.Completed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public bool Execute(CommandProcessorContext context, string[] args)
{
var fromOffset = 0;
int maxRecordCount = int.MaxValue;
if (args.Length > 0)
{
if (args.Length > 2)
{
context.Log.Info("More arguments: {0}", args.Length);
return false;
}
int.TryParse(args[0], out fromOffset);
if (args.Length > 1)
int.TryParse(args[1], out maxRecordCount);
}
context.IsAsync();
var result = _reader.ReadAll(fromOffset, maxRecordCount);
var dataRecords = result as DataRecord[] ?? result.ToArray();
context.Log.Info("Read {0} records{1}", dataRecords.Length, dataRecords.Length > 0 ? ":" : ".");
foreach (var record in dataRecords)
{
context.Log.Info(" stream-id: {0}, data: {0}", record.Key, Encoding.UTF8.GetString(record.Data));
}
var nextOffset = dataRecords.Length > 0 ? dataRecords.Last().NextOffset : 0;
context.Log.Info("Next stream offset: {0}", nextOffset);
context.Completed();
return true;
}
示例2: Execute
public bool Execute(CommandProcessorContext context, string[] args)
{
var eventStreamId = "default stream";
var expectedVersion = -1;
var data = "default-data";
if (args.Length > 0)
{
if (args.Length != 3)
{
context.Log.Info("More arguments: {0}",args.Length);
return false;
}
eventStreamId = args[0];
int.TryParse(args[1], out expectedVersion);
data = args[2];
}
context.IsAsync();
context.Client.JsonClient.Post<ClientDto.WriteEvent>("/stream", new ClientDto.WriteEvent()
{
Data = Encoding.UTF8.GetBytes(data),
Stream = eventStreamId,
ExpectedVersion = expectedVersion
});
context.Completed();
return true;
}
示例3: Execute
public bool Execute(CommandProcessorContext context, string[] args)
{
context.IsAsync();
long total = 0;
int count = 0;
var threads = new List<Task>();
int threadCount = 5;
var size = 1000;
if (args.Length > 0)
int.TryParse(args[0], out threadCount);
if (args.Length > 1)
int.TryParse(args[1], out size);
var global = Stopwatch.StartNew();
for (int t = 0; t < threadCount; t++)
{
var task = Task.Factory.StartNew(() =>
{
var watch = Stopwatch.StartNew();
for (int i = 0; i < size; i++)
{
context.Client.JsonClient.Post<ClientDto.WriteEvent>("/stream", new ClientDto.WriteEvent()
{
Data = Encoding.UTF8.GetBytes("This is some test message to load the server"),
Stream = "name",
ExpectedVersion = -1
});
//client.Get<ClientDto.WriteEvent>("/stream/name");
}
Interlocked.Add(ref total, watch.Elapsed.Ticks);
Interlocked.Add(ref count, size);
}, TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness);
threads.Add(task);
}
Task.WaitAll(threads.ToArray());
context.Completed();
context.Log.Info("{0} per second", count / global.Elapsed.TotalSeconds);
PerfUtils.LogTeamCityGraphData(string.Format("{0}-latency-ms", Key), (int)(count / global.Elapsed.TotalSeconds));
return true;
}