Exemple #1
0
        private void backgroundWorker_GUI_Reader(object sender, DoWorkEventArgs e)
        {
            //Init
            UpdateLogCallback updateTree    = new UpdateLogCallback(UpdateTree);
            string            dataFromUnity = null;

            try
            {
                while (NPtoGUI.IsConnected == false)
                {
                    Thread.Sleep(100);
                }

                StreamString serverStream = new StreamString(NPtoGUI);

                while (true)
                {
                    int    msgLength = Convert.ToInt32(serverStream.ReadString());
                    byte[] readBytes = new byte[msgLength];
                    NPtoGUI.Read(readBytes, 0, msgLength);
                    dataFromUnity = Encoding.ASCII.GetString(readBytes);

                    CommonTree loadedTree = new CommonTree();
                    Invoke(updateTree, new object[] { dataFromUnity });
                }
            }
            catch (Exception ex)
            {
                //Handle usual Communication Exceptions here - just logging here for demonstration and debugging Purposes
                //Invoke(updateLog, new object[] { ex.Message });
            }
        }
Exemple #2
0
        private void backgroundWorker_GUI_Writer(object sender, DoWorkEventArgs e)
        {
            //Init
            //UpdateLogCallback updateLog = new UpdateLogCallback(UpdateLog);

            try
            {
                while (NPtoUnity.IsConnected == false)
                {
                    Thread.Sleep(100);
                }

                serverStream = new StreamString(NPtoUnity);
            }
            catch (Exception ex)
            {
                //Invoke(updateLog, new object[] { ex.Message });
            }
        }