MSDN文档显示 DataflowBlockOptions 类中有一个
还是...如我所料...这只是未实现的设计残留吗?
NameFormat
属性,描述如下:
那么...如何设置名称?名称在何处可用?什么时候使用?获取或设置查询块名称时要使用的格式字符串。
还是...如我所料...这只是未实现的设计残留吗?
NameFormat
属性,描述如下:
那么...如何设置名称?名称在何处可用?什么时候使用?获取或设置查询块名称时要使用的格式字符串。
NameFormat
,最终将导致生成一个名称(您当然可以忽略参数并设置任何您想要的名称,如NameFormat = "bar"
)。您可以使用ToString
获取名称,例如:var block = new ActionBlock<int>(_ => { }, new ExecutionDataflowBlockOptions
{
NameFormat = "The name format may contain up to two format items. {0} will be substituted with the block's name. {1} will be substituted with the block's Id, as is returned from the block's Completion.Id property."
});
Console.WriteLine(block.ToString());
输出:
名称格式可以包含最多两个格式项。ActionBlock`1将被替换为块的名称。1将被替换为块的Id,就像从块的Completion.Id属性返回的那样。
如果我们查看.Net Core上的源代码,ToString
实现基本上是:
return string.Format(options.NameFormat, block.GetType().Name, block.Completion.Id);