I have an image stitching task that could take a lot of time so I run it as a seperate task like this
var result = openFileDialog.ShowDialog();
BeginInvoke(new Action<string[]>(StitchTask), openFileDialog.FileNames);
private void StitchTask(string[] fileNames)
{
// this task could take a lot of time
}
Do I need to worry about the co-variant array conversion warning below or am I doing something wrong?
Co-variant array conversion from string[] to object[] can cause
run-time exception on write operation
Got it – the problem is that you’re passing a
string[]as if it were an array of arguments for the delegate, when you actually want it as a single argument:Whatever’s giving you the warning is warning you about the implicit conversion of
string[]toobject[], which is reasonable because something taking anobject[]parameter might try to write:In this case that isn’t the problem… but the fact that it would try to map each string to a separate delegate parameter is a problem.