コード例 #1
0
ファイル: Form1.cs プロジェクト: sinrey/SR_DeviceInterface
        private void SDFilePlayThread(object obj)
        {
            IPAddress   localaddr = IPAddress.Parse("0.0.0.0");
            TcpListener tcpserver = new TcpListener(localaddr, 0);

            tcpserver.Start();
            IPEndPoint localep = (IPEndPoint)tcpserver.LocalEndpoint;

            WorkProcessHandler h = new WorkProcessHandler(UploadFileProcess);

            ThreadParam ap = (ThreadParam)obj;

            DeviceListener.Device d = deviceListener.Find(ap.id);
            if (d == null)
            {
                return;
            }
            string fname = System.IO.Path.GetFileName(ap.filename);
            int    ret   = deviceListener.SDCardPlayFile(d, fname, ap.volume);

            if (ret != 0)
            {
                return;
            }
            TcpClient tc = null;

            try
            {
                while (true)
                {
                    int ret2 = deviceListener.SDCardGetPlayFileStatus(d, out string filename, out int runtime, out int process);
                    if (ret2 == 0)
                    {
                        this.BeginInvoke(h, d, filename, false, process);
                    }
                    else
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                }
                this.BeginInvoke(h, d, null, true, 0);

                dataThread = null;
            }
            catch (ThreadAbortException abortException)
            {
                dataThread = null;
            }
        }
コード例 #2
0
        private void SDFilePlayThread(object obj)
        {
            WorkProcessHandler h = new WorkProcessHandler(SDPlayFileProcess);

            ThreadParam ap = (ThreadParam)obj;

            DeviceListener.Device d = deviceListener.Find(ap.id);
            if (d == null)
            {
                this.BeginInvoke(h, d, null, true, -1);
                return;
            }
            string fname = System.IO.Path.GetFileName(ap.filename);
            int    ret   = deviceListener.SDCardPlayFile(d, fname, ap.volume);

            if (ret != 0)
            {
                this.BeginInvoke(h, d, null, true, -2);
                return;
            }
            //TcpClient tc = null;
            try
            {
                while (true)
                {
                    int ret2 = deviceListener.SDCardGetPlayFileStatus(d, out string filename, out int runtime, out int process);
                    if (ret2 == 0)
                    {
                        this.BeginInvoke(h, d, filename, false, process);
                    }
                    else
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                }
                this.BeginInvoke(h, d, null, true, 0);
            }
            catch (ThreadAbortException abortException)
            {
            }
            finally
            {
            }
        }