title: How to define the event handler in another class?
body: <p>I tried to define the <code>UploadStringCompleted</code> of <code>Webclient</code> outside the class <code>PanelAPI</code>, so I define a variable <code>requestTokenCompleted</code>.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Text;
  using System.Net;
  using Newtonsoft.Json;
  
  namespace Shadowsocks.Controller
  {
      class PanelAPI
      {
          private string baseURL = "https://test.com/api";
          public event UploadStringCompletedEventHandler requestTokenCompleted;
          public event DownloadStringCompletedEventHandler requestServersCompleted;
  
          public void requestToken(string email, string passwd)
          {
              var logInfo = new { email = email, passwd = passwd };
              WebClient client = new WebClient();
  
              Uri uri = new Uri($"{baseURL}/token");
  
              client.Headers[HttpRequestHeader.ContentType] = "application/json";
  
              client.UploadStringCompleted += requestTokenCompleted;
              client.UploadStringAsync(uri, JsonConvert.SerializeObject(logInfo));
          }
  
  
      }
  }
  </code></pre>
  
  <p>Now I tried to implement <code>requestTokenCompleted</code> in the <code>Authform</code> class. But <code>requestTokenCompleted</code> is not executed when I call <code>api.requestToken()</code>. How can I fix it？</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Text;
  using Shadowsocks.Controller;
  using Shadowsocks.Model;
  using System.Net;
  using System.Windows.Forms;
  
  
  namespace Shadowsocks.View
  {
      public partial class AuthForm : Form
      {
          public AuthForm(ShadowsocksController controller)
          {
              InitializeComponent();
          }
  
          private void AuthForm_Load(object sender, EventArgs e)
          {
  
          }
  
          private void LoginButton_Click(object sender, EventArgs e)
          {
              var _config = Configuration.Load();
              _config.userProfile.email = emailTextBox.Text;
              _config.userProfile.passwd = pwdTextBox.Text;
  
              Configuration.Save(_config);
  
              var api = new PanelAPI();
  
              api.requestTokenCompleted += requestTokenCompleted;
              api.requestToken(emailTextBox.Text, pwdTextBox.Text);
          }
  
          private void requestTokenCompleted(Object sender, UploadStringCompletedEventArgs e)
          {
              Console.WriteLine("requestTokenCompleted");
          }
      }
  }
  </code></pre>