hustino siat

hustino siat

  • NA
  • 68
  • 7.5k

to instert the timer and the peek and contain method in C# visual stud

Oct 15 2021 6:37 AM

I created 3 Windows Form in visual studio 2015. 

I cant understand where to inster the timer and the peek and contain method

CashierClass - classclass CashierClass {
  private int x;
  public static string getNumberInQueue = " ";
  public static Queue CashierQueue;
  public CashierClass() {
    x = 10000;
    CashierQueue = new Queue();
  }
  public string CashierGeneratedNumber(string CashierNumber) {
    x++;
    CashierNumber = CashierNumber + x.ToString();
    return CashierNumber;
  }
}
QueuingForm - windowsformpublic partial class QueuingForm: Form {
    private CashierClass cashier;
    private int openForms;
    public QueuingForm(params Form[] forms) {
      InitializeComponent();
      openForms = forms.Length;
      foreach(var form in forms) {
        form.FormClosed += (s, args) => {
          //When we have closed the last of the "starting" forms, //end the program.
          if (Interlocked.Decrement(ref openForms) == 0) ExitThread();
        };
        form.Show();
      }
      cashier = new CashierClass();
    }
    private void ExitThread() {
      throw new NotImplementedException();
    }
    private void btnCashier_Click(object sender, EventArgs e) {
      lblQueue.Text = cashier.CashierGeneratedNumber("P - ");
      CashierClass.getNumberInQueue = lblQueue.Text;
      CashierClass.CashierQueue.Enqueue(CashierClass.getNumberInQueue);
    }
    CashierWindowsQueueProgramForm - windows formpublic partial class CashierWindowsQueuingForm: Form {
        Stack sn = new Stack();
        public CashierWindowsQueuingForm() {
          InitializeComponent();
          Timer refresh = new Timer();
          refresh.Interval = (1 * 1000);
          refresh.Tick += new EventHandler(refresh_Tick);
          refresh.Start();
        }
        public void DisplayCashierQueue(IEnumerable CashierList) {
          listCashierQueue.Items.Clear();
          foreach(Object obj in CashierList) {
            listCashierQueue.Items.Add(obj.ToString());
          }
        }
        private void btnRefresh_Click(object sender, EventArgs e) {
          DisplayCashierQueue(CashierClass.CashierQueue);
          CashierClass.CashierQueue.Dequeue();
        }
        private void btnNext_Click(object sender, EventArgs e) {
          sn.Push(CashierClass.getNumberInQueue);
        }
        private void CashierWindowsQueuingForm_Load(object sender, EventArgs e) {
          this.Update();
        }
        ServingForm - windows formpublic partial class ServingForm: Form {
          CashierClass num = new CashierClass();
          public string h;
          public ServingForm() {
            InitializeComponent();
          }
          public void DisplayCashierQueue(IEnumerable CashierList) {}
          private void lblServingNum_Click(object sender, EventArgs e) {}
        }