MSDN documentation shows that there is a NameFormat
attribute on the DataflowBlockOptions
class, described as:
Gets or sets the format string to use when a block is queried for its name.
So ... how do you set the name? How is the name available? When is it used?
Or ... as I suspect ... is this just a remnant of design that didn't actually get implemented?
You don't set the name, you set a NameFormat
that will eventually result in a name (you can of course disregard the parameters and set whatever you want like NameFormat = "bar"
) . You may get the name by using ToString
, for example:
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());
Output:
The name format may contain up to two format items. ActionBlock`1 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.
If we look at the source code on .Net Core the ToString
implementation is basically:
return string.Format(options.NameFormat, block.GetType().Name, block.Completion.Id);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With