本文整理汇总了C#中EventHandler.SafeInvoke方法的典型用法代码示例。如果您正苦于以下问题:C# EventHandler.SafeInvoke方法的具体用法?C# EventHandler.SafeInvoke怎么用?C# EventHandler.SafeInvoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventHandler
的用法示例。
在下文中一共展示了EventHandler.SafeInvoke方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RaiseEvent
private void RaiseEvent(string name, EventHandler<QueueActionEventArgs> eventHandler, Queue queue)
{
logger.Info("hub " + name + " " + queue.Id + " " + queue.Status);
eventHandler.SafeInvoke(this, new QueueActionEventArgs(queue));
}
示例2: ChangeStatus
public void ChangeStatus(UserStatus status, EventHandler<ReplyEventArgs> callback)
{
VerifyLoggedIn();
Contract.Requires(protocol != null);
var message = protocol.CreateMessage("me.status");
message["status"] = status.ToString();
protocol.SendMessage(message, (messageName, result, reply) =>
{
ReplyEventArgs args;
switch (result)
{
case Network.ReplyResult.Success:
me.Update(new UserDescription()
{
Name = me.Name,
DisplayName = me.DisplayName,
Status = status,
Friend = false,
});
var meArray = new IUser[] { me };
UserDetailsChange.SafeInvoke(this, new UserDetailsEventArgs(Enumerable.Empty<IUser>(), meArray));
args = new ReplyEventArgs(Convert.ToInt32(reply["result"]), Convert.ToString(reply["result_message"]));
break;
case Network.ReplyResult.Fail:
args = new ReplyEventArgs((int) ResultCode.NotSent, MessageNotSentString);
break;
case Network.ReplyResult.Expired:
args = new ReplyEventArgs((int) ResultCode.NoReply, NoReplyString);
break;
default:
throw new Exception("This should not happen");
}
callback.SafeInvoke(this, args);
});
}