public ServerReplyMessage GetServerReply(IRCReplyCode replyCode, string match) { GetReply reply = new GetReply(); reply.Reply = replyCode; reply.Match = match; ServerReplyEvent += (sender, e) => HandleReply(sender, e, reply); reply.Ready.Wait(TimeSpan.FromMilliseconds(5000)); return(reply.Result); }
private void HandleReply(object sender, IReply message, GetReply reply) { bool replyFound = false; Regex replyRegex = new Regex(reply.Match); if (message.GetType() == typeof(ServerReplyMessage)) { ServerReplyMessage msg = (ServerReplyMessage)message; replyFound = reply.Reply.Equals(msg.ReplyCode); if (replyFound && replyRegex.IsMatch(msg.Message)) { reply.Result = msg; reply.Ready.Set(); } } }