Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass multiple parameters to BeginInvoke()

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);
like image 893
demo Avatar asked Aug 17 '15 15:08

demo


1 Answers

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.

like image 60
sstan Avatar answered Sep 22 '22 20:09

sstan