First of there is some code missing, I'm sure it's in your project but in order to be able to give an accurate answer you need to provide the following.
flag
is not defined anywhere and it's not being assinged a value anywhere either.
Since I can't see how flag is treated I'm going to assume that
flag
is true when you call
client.JoinChat(username);
in
login_btn_Click
and in that case
Newjoin
is null when no handler has been assigned to the event. So you need to check for null.
if (flag == true)
{
ListofUsers.Add(name);
MessageBox.Show("User Logged in");
UserJoin handler = Newjoin;
if(handler != null)
handler (name);
}