本文整理匯總了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);
});
}