dem*_*emo 2 c# asynchronous begininvoke
我有简单的逻辑(我认为)。
public static void NotifyAboutNewJob(int jobId, bool forceSending = false)
{
Action<int> notifier = SendAppleNotifications;
notifier.BeginInvoke(jobId, null, null);
}
Run Code Online (Sandbox Code Playgroud)
方法SendAppleNotifications有一个参数a,很容易传递给它BeginInvoke。现在,我添加了第二个参数forceSending。问题-我不知道如何将其传递给BeginInvoke。
我应该将其作为第三参数传递object吗?
private static void SendAppleNotifications(int jobId, bool forceSending = false){...}
Run Code Online (Sandbox Code Playgroud)
或这就是答案:
Action<int, bool> notifier = SendAppleNotifications;
notifier.BeginInvoke(jobId, forceSending, null, null);
Run Code Online (Sandbox Code Playgroud)
更改Action<int>为Action<int, bool>
Action<int, bool> notifier = SendAppleNotifications;
notifier.BeginInvoke(jobId, forceSending, null, null); // You can now pass true or false as 2nd parameter.
Run Code Online (Sandbox Code Playgroud)
那就应该可以了
| 归档时间: |
|
| 查看次数: |
4518 次 |
| 最近记录: |