Consider use case: I need to pass a parameter to QueueUserWorkItem
:
ThreadPool.QueueUserWorkItem((o) =>
{
var item = o as MyObject;
},
item);
Then requirements changed and I now need to pass 2 objects. So I would have to write something like:
ThreadPool.QueueUserWorkItem((o) =>
{
var items = o as Tuple<MyObject,MyObject2>;
},
new Tuple<MyObject,MyObject2>(item1, item2));
Is there a cleaner way to achieve this in C# 9+ ?