Example #1
0
 public void AddUserToChannel(ChanUser cu)
 {
     try
     {
         for (int i = 0; i < this.lstUsers.Items.Count; i++)
         {
             // For an ascending sort, we keep going until we find something we aren't >,
             // then insert ourselves there.
             // We then just return. The finally block will trip to refresh the listbox before the
             // return kicks us all the way out.
             if (cu.CompareTo(lstUsers.Items[i]) < 1)
             {
                 // cu is less than or equal to lstUsers.Items[i]. That's where we insert.
                 lstUsers.Items.Insert(i, cu);
                 return;                         // Now get the heck out of this proc.
             }
         }
         this.lstUsers.Items.Add(cu);
     }
     // A fun hack to get this Refresh to happen come hell or high water.
     // Hint: finally blocks run when code leaves a try or catch block in ANY WAY OR FORM.
     // Whether by hitting the }, throwing up, breaking, or even return.
     finally
     {
         this.lstUsers.Refresh();
     }
 }
Example #2
0
 public void AddUserToChannel(ChanUser cu)
 {
     try
     {
         for (int i = 0; i < this.lstUsers.Items.Count; i++)
         {
             // For an ascending sort, we keep going until we find something we aren't >,
             // then insert ourselves there.
             // We then just return. The finally block will trip to refresh the listbox before the
             // return kicks us all the way out.
             if (cu.CompareTo(lstUsers.Items[i]) < 1)
             {
                 // cu is less than or equal to lstUsers.Items[i]. That's where we insert.
                 lstUsers.Items.Insert(i, cu);
                 return; // Now get the heck out of this proc.
             }
         }
         this.lstUsers.Items.Add(cu);
     }
         // A fun hack to get this Refresh to happen come hell or high water.
         // Hint: finally blocks run when code leaves a try or catch block in ANY WAY OR FORM.
         // Whether by hitting the }, throwing up, breaking, or even return.
     finally
     {
         this.lstUsers.Refresh();
     }
 }