Search Results

Search found 1 results on 1 pages for 'user1886060'.

Page 1/1 | 1 

  • Timer C#. Start, stop, and get the amount of time between the calls

    - by user1886060
    I'm writing UDP chat with reliable data transfer. I need to start a timer when a packet is sent, and stop it as soon it receives an answer from the server(ACK- acknowledgment). Here is my code: private void sendButton_Click(object sender, EventArgs e) { Packet snd = new Packet(ack, textBox1.Text.Trim()); textBox1.Text = string.Empty; Smsg = snd.GetDataStream();//convert message into array of bytes to send. while (true) { try { // Here I need to Start a timer! clientSock.SendTo(Smsg, servEP); clientSock.ReceiveFrom(Rmsg, ref servEP); //Here I need to stop a timer and get elapsed amount of time. Packet rcv = new Packet(Rmsg); if (Rmsg != null && rcv.ACK01 != ack) continue; if (Rmsg != null && rcv.ACK01 == ack) { this.displayMessageDelegate("ack is received :"+ack); ChangeAck(ack); break; } Thank you.

    Read the article

1