One quick and dirty solution would be to add a default value after calling the Delete method. In any case, it will be ignored unless you assign the result of the Invoke method to a variable. For example, the following code demonstrates this:
Invoke(() => {CustomVariableGroupLogic.Delete(customVariableGroup); return 0; });
You can see a similar example suggested here ,
If you have many, many such calls, you can create a fancy shell that will return Func for this Action . Example:
Func<Action, Func<int>> wrap = action => () => {action(); return 0;};
Now you can
Invoke(() => wrap(() => CustomVariableGroupLogic.Delete(customVariableGroup)));
but it's a little closer to lambda madness
Inspired by pcm2 :
you can create an overload for Invoke that simply takes Action as a parameter, use the solution above to invoke the implementation using Func<T> :
public void Invoke(Action action) { Invoke(() => {action(); return 0;}); }
now you just can
Invoke(() => CustomVariableGroupLogic.Delete(customVariableGroup));
source share