private void OnNewTag(string tag) { // from https://msdn.microsoft.com/en-us/library/w369ty8x.aspx // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. EventHandler <NewTagEventArgs> handler = NewTagEvent; // Event will be null if there are no subscribers if (handler != null) { NewTagEventArgs e = new NewTagEventArgs(tag); handler(this, e); } }
private void Login(object sender, NewTagEventArgs e) { this.Invoke((MethodInvoker) delegate { this.LoginMain(e.Tag); }); }