Exemple #1
0
 //get all of the commands and push them to the queue
 private void GetCommands()
 {
     //basic params
     using (NetworkStream ns = client.GetStream())
         using (BinaryWriter writer = new BinaryWriter(ns))
         {
             while (client.Connected)
             {
                 string[] toEnqueue = new string[commands.Length];
                 for (int i = 0; i < commands.Length; i++)
                 {
                     //get the command and parse it to definitly end with \r\n
                     string commandToSend = Regex.Replace(commands[i], @"\n|\r", "") + "\r\n";
                     //send the command
                     writer.Write(commandToSend.ToCharArray());
                     //read information
                     StreamReader reader = new StreamReader(ns);
                     toEnqueue[i] = reader.ReadLine();
                 }
                 NotifyDataAdded(toEnqueue);
                 //push the information to the queue
                 data.Enqueue(toEnqueue);
                 if (timesPerSecond != 0)
                 {
                     Thread.Sleep(1000 / timesPerSecond);
                 }
                 else
                 {
                     break;
                 }
             }
         }
 }
Exemple #2
0
        private void ReadFile()
        {
            List <string[]> toRead = ReaderWriter.readFile(fileName);

            foreach (string[] point in toRead)
            {
                NotifyDataAdded(point);

                //push the information to the queue
                data.Enqueue(point);
                if (timesPerSecond != 0)
                {
                    Thread.Sleep(1000 / timesPerSecond);
                }
                else
                {
                    break;
                }
            }
        }