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);