There is a Task.Factory.StartNew(Action<Object> action, Object state) method. This looks generic. But, if my “action” is
protected void Edit(MyType myType) { }
why can’t I have
MyType x = something;
Task.Factory.StartNew(Edit, x);
I get:
Argument 1: cannot convert from ‘method group’ to ‘System.Action’
I can get it to work by adding another method,
protected void Edit(object myType) { Edit((MyType)myType); }
or I can write
Task.Factory.StartNew(() => Edit(x));
but I feel like I’m missing something that should allow me to do it the first way…
The
Editmethod group is not convertible toAction<object>. You could dobut there is no conversion between
Action<MyType>andAction<object>. If there were you could do