How is it possible that this code
TaskManager.RunSynchronously<MyObject>(fileMananager.BackupItems, package);
causes a compile error
The call is ambiguous between the following methods or properties:
'TaskManager.RunSynchronously<MyObject>(System.Action<MyObject>, MyObject)' and
'TaskManager.RunSynchronously<MyObject>(System.Func<MyObject, bool>, MyObject)'
when signature of the action is
public void BackupItems(MyObject package)
and "ambiguous" methods are
static class TaskManager
{
public static void RunSynchronously<TInput>(Action<TInput> task, TInput param)
{
Task.Factory.StartNew(() => task(param));
}
public static bool RunSynchronously<TInput>(Func<TInput, bool> task, TInput param)
{
return Task.Factory.StartNew(() => task(param)).Result;
}
}
It seems to me that there is an ample difference between these methods. What am I missing here?
EDIT:
Besides the accepted answer I just came across a solution in a similar question. Here is the link.