Beispiel #1
0
 private void OnStatusUpdated(object sender, StatusEventArgs e)
 {
     if (e.Type == NetworkUtility.requestStatus) //Request status
     {
         if (e.Status == NetworkUtility.sucessfulStatus)
         {
             lstStatus.Items.Insert(0, NetworkUtility.GetStatusInfo(e.Type, e.Status,
                                                                    NetworkUtility.GetRequestInfo(operation, client.GetDataLength())));
             //request success and receive data now
             client.ReceiveData(Int32.Parse(txtTimeout.Text));
         }
         else
         {
             lstStatus.Items.Insert(0, NetworkUtility.GetStatusInfo(e.Type, e.Status, null));
             grid.IsEnabled = true;
         }
     }
     else if (e.Type == NetworkUtility.receiveStatus)    //Receive status
     {
         if (e.Status == 0)
         {
             if (operation == NetworkUtility.encodeOper)
             {
                 count++;
             }
             else if (operation == NetworkUtility.decodeOper)
             {
                 count--;
             }
         }
         //update UI about the response.
         lblEncodeCycleCount.Content = count + " (cycle count)";
         lstStatus.Items.Insert(0, NetworkUtility.GetStatusInfo(e.Type, e.Status, null));
         grid.IsEnabled = true;
     }
 }
Beispiel #2
0
 public void GenerateData(int dataSize)
 {
     data = NetworkUtility.GenerateData(dataSize);
 }
 public DataSender()
 {
     utility = new NetworkUtility();
     thread = new Thread(Run);
     thread.Start();
 }