7

I have simple (as i think) logic.

public static void NotifyAboutNewJob(int jobId, bool forceSending = false)
{
        Action<int> notifier = SendAppleNotifications;
        notifier.BeginInvoke(jobId, null, null);
}

Method SendAppleNotifications had one parametera and it was easy to pass it into BeginInvoke. Now i have added second parameter forceSending. And problem - i don't know how to pass it into BeginInvoke.

Should i pass it as 3rd param as object ?

private static void SendAppleNotifications(int jobId, bool forceSending = false){...}

Or this is the answer :

Action<int, bool> notifier = SendAppleNotifications;
notifier.BeginInvoke(jobId, forceSending, null, null);
demo
  • 6,038
  • 19
  • 75
  • 149

1 Answers1

8

Change your Action<int> to Action<int, bool>

Action<int, bool> notifier = SendAppleNotifications;
notifier.BeginInvoke(jobId, forceSending, null, null); // You can now pass true or false as 2nd parameter.

then it should work ok.

sstan
  • 35,425
  • 6
  • 48
  • 66