title: Why does the ainteger setting not work right?
body: <p>I have two versions of code. The first version doesn't work, the second version does. Why does the first version's ainteger setting not work right?  It is suppose to cause "Player One" and "Player Two" to be displayed above the buttons on the second register button press. I have included the code below.</p>
  
  <p>To be more specific the program is supposed to call the server's register function when the register button is pressed.  The server sets the value in the html, using the server's setinteger() when its integer value is one.  When the client's ainteger is two (second time register key was pressed,) the event handler will call the server's printthename() function.  This in turn calls the client's printname() and printname2() and displays the names.  These names are not being displayed!</p>
  
  <ul>
  <li>By tracing the error, when the button is hit twice , the register button event is not breaking in the register buttons event handler, and the block for the ainteger does not seem to be calling the printthename().  It does however show up in the server's register function when the server's integer value is one.</li>
  </ul>
  
  <p>The program uses SignalR and two explorer tabs with Visual Studio 2019. </p>
  
  <p>I have tried changing the code, slimmed it down, made it simple, and traced. And printthename() called from setinteger() is a version that works.</p>
  
  <p>The GitHub link is : <a href="https://github.com/Joshei/signalr1" rel="nofollow noreferrer">https://github.com/Joshei/signalr1</a></p>
  
  <p>Branch 3 : new version, works. </p>
  
  <p>Branch 4 : old version, doesn't work (doesn't display the names.)</p>
  
  <p>The Visual Studio version has comments to explain that there is no way this is causing any problems. </p>
  
  <p>/////////////////////////////////////HUB://///////////////////////////////////</p>
  
  <pre><code>
      public class ChatHub : Hub
      {
  
  
          private static readonly List&lt;clients&gt; ClientList = new List&lt;clients&gt;();
  
          public  void printthename()
          {
              string name = "";
              if (whoseturn == 0)
              {
  
  
                  name = "Player one ";
                  Clients.Client(ClientList[0].ConnectionId).printname(name);
                  name = "Player two ";
                  Clients.Client(ClientList[1].ConnectionId).printname2(name);
              }
  
          }
          public void register(string name1)
          {
  
              clients A_Client = new clients();
  
              A_Client.ConnectionId = Context.ConnectionId;
              A_Client.Name = name1;
              ClientList.Add(A_Client);
  
              if (integer == 0)
              {
  
                  integer = integer + 1;
              }
              else if (integer == 1)
              {
                 Clients.Client(ClientList[1].ConnectionId).setinteger();
                 Clients.Client(ClientList[0].ConnectionId).setinteger();
              }
  
          }
  }
  </code></pre>
  
  <p>/////////////////////////////////////HTML CLIENT://///////////////////////////////////</p>
  
  <pre><code>$(function () {
  
          var ainteger = "0";
  
              $("#Join").click(function () {
              $('#Join').hide();
              $('#Name').hide();
  
              chat.server.register("a");
  
              if (ainteger == "1") {
  
                  chat.server.printthename();
              }
  
          });
  
  
          chat.client.setinteger =   function () {
  
              ainteger = "1";
  
          };
  
  
  
  
      });
  
  
  </code></pre>
  
  <p>Thank you, I have been trying to get this working since November 30.</p>