我在代码实现方面遇到了困难。我目前正在使用PushSharp库,其中一件我想做的事情是,如果事件被触发,我想根据事件返回一个true或false的值。以下是代码:
public static bool SenddNotification()
{
var push = new PushBroker();
//Wire up the events for all the services that the broker registers
push.OnNotificationSent += NotificationSent;
push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
}
static bool DeviceSubscriptionChanged(object sender, string oldSubscriptionId, string newSubscriptionId, INotification notification)
{
//Currently this event will only ever happen for Android GCM
Console.WriteLine("Device Registration Changed: Old-> " + oldSubscriptionId + " New-> " + newSubscriptionId + " -> " + notification);
return false;
}
static bool NotificationSent(object sender, INotification notification)
{
Console.WriteLine("Sent: " + sender + " -> " + notification);
return true;
}
如果事件触发,希望返回true或false取决于发生了什么,然后最终在第一个方法中返回此值。