本文整理汇总了C#中ISource.Read方法的典型用法代码示例。如果您正苦于以下问题:C# ISource.Read方法的具体用法?C# ISource.Read怎么用?C# ISource.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISource
的用法示例。
在下文中一共展示了ISource.Read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JobEntry
public async Task JobEntry(string name, int interval, ISource source, IEnumerable<IIntermedia> intermedias, ISink sink, CancellationToken ct)
{
try
{
while (true)
{
//Read data set from source filter
DataSet dataset = await source.Read(ct);
if (dataset == null || !dataset.Any())
{
//Skip current loop if no data read, or filter is in status "stopping"
goto loop;
}
//Process data set by intermedia filters
foreach (var intermedia in intermedias)
{
//dataset = await intermedia.Process(dataset, ct);
dataset = await intermedia.Process(dataset, ct, DeviceId);//Chris Han add DeviceId to Json
if (dataset == null || !dataset.Any())
{
//Skip current loop if no data read, or filter is in status "stopping"
goto loop;
}
}
//Individually sink each data, to help down-stream Job in aggregating
foreach (var data in dataset)
{
await sink.Write(data, ct);
}
loop:
await Task.Delay(interval, ct);
}
}
catch (OperationCanceledException)
{
Trace.TraceInformation(string.Format(CultureInfo.InvariantCulture, "Job {0}.{1} finished", DeviceId, name));
}
catch (Exception ex)
{
Trace.TraceError(string.Format(CultureInfo.InvariantCulture, "Job {0}.{1} stopped due to exception {2}", DeviceId, name, ex.ToString()));
}
}