Init() public method

public Init ( String sServer, int iPort, byte byData, int iSleep, int iIDThread, bool bVideo, int iMode ) : void
sServer String
iPort int
byData byte
iSleep int
iIDThread int
bVideo bool
iMode int
return void
Beispiel #1
0
        private void butStartStop_Click(object sender, EventArgs e)
        {
            _bStart = !_bStart;
            int i;

            if (_bStart)
            {
                _iSec             = 0;
                butStartStop.Text = "Stop";
                byte[] byA = new byte[13];
                byte[] byV = new byte[1024];
                byA[0] = byV[0] = 11;
                int ii = 0;
                listBox1.Items.Clear();
                for (i = 0; i < Convert.ToInt32(txtThread.Text); i++)
                {
                    Worker workV = new Worker();
                    _Workers.Add(workV);
                    if (ii == 0 && cmbCmd.SelectedIndex == 0)
                    {
                        byV[0] = 13;
                    }
                    else if (cmbCmd.SelectedIndex == 1)
                    {
                        byV[0] = 13;
                    }
                    else if (cmbCmd.SelectedIndex == 2)
                    {
                        byV[0] = 11;
                    }
                    else if (ii != 0 && cmbCmd.SelectedIndex == 0)
                    {
                        byV[0] = 11;
                    }
                    workV.Init(txtServer.Text, 9051, byV, 66, ii, true, cmbMode.SelectedIndex);
                    listBox1.Items.Add(ii.ToString() + "_Video");
                    Thread thV = new Thread(workV.DoWork);
                    _Th.Add(thV);
                    thV.Start();
                    workV.StartStop(true);

                    ii++;
                    if (cmbMode.SelectedIndex != 1)
                    {
                        Worker workA = new Worker();
                        _Workers.Add(workA);
                        workA.Init(txtServer.Text, 9052, byA, 18, ii, false, cmbMode.SelectedIndex);
                        listBox1.Items.Add(ii.ToString() + "_Audio");
                        ii++;
                        Thread thA = new Thread(workA.DoWork);
                        _Th.Add(thA);
                        thA.Start();
                        workA.StartStop(true);
                    }
                }
            }
            else
            {
                butStartStop.Text = "Start";
                for (i = 0; i < _Workers.Count; i++)
                {
                    Worker w = (Worker)_Workers[i];
                    w.RequestStop();
                    Thread t = (Thread)_Th[i];
                    //t.Join();
                }
                _Workers.Clear();
                _Th.Clear();
            }
            timer1.Enabled = _bStart;
        }
Beispiel #2
0
        private void butStartStop_Click(object sender, EventArgs e)
        {
            _bStart = !_bStart;
            int i;

            if (_bStart)
            {
                _iSec = 0;
                butStartStop.Text = "Stop";
                byte[] byA = new byte[13];
                byte[] byV = new byte[1024];
                byA[0] = byV[0] = 11;
                int ii = 0;
                listBox1.Items.Clear();
                for (i = 0; i < Convert.ToInt32(txtThread.Text); i++)
                {
                    Worker workV = new Worker();
                    _Workers.Add(workV);
                    if (ii == 0 && cmbCmd.SelectedIndex == 0)
                        byV[0] = 13;
                    else if (cmbCmd.SelectedIndex == 1)
                        byV[0] = 13;
                    else if (cmbCmd.SelectedIndex == 2)
                        byV[0] = 11;
                    else if (ii != 0 && cmbCmd.SelectedIndex == 0)
                        byV[0] = 11;
                    workV.Init(txtServer.Text, 9051, byV, 66, ii, true, cmbMode.SelectedIndex);
                    listBox1.Items.Add(ii.ToString() + "_Video");
                    Thread thV = new Thread(workV.DoWork);
                    _Th.Add(thV);
                    thV.Start();
                    workV.StartStop(true);

                    ii++;
                    if (cmbMode.SelectedIndex != 1)
                    {
                        Worker workA = new Worker();
                        _Workers.Add(workA);
                        workA.Init(txtServer.Text, 9052, byA, 18, ii, false, cmbMode.SelectedIndex);
                        listBox1.Items.Add(ii.ToString() + "_Audio");
                        ii++;
                        Thread thA = new Thread(workA.DoWork);
                        _Th.Add(thA);
                        thA.Start();
                        workA.StartStop(true);
                    }
                }
            }
            else
            {
                butStartStop.Text = "Start";
                for (i = 0; i < _Workers.Count; i++)
                {
                    Worker w = (Worker)_Workers[i];
                    w.RequestStop();
                    Thread t = (Thread)_Th[i];
                    //t.Join();
                }
                _Workers.Clear();
                _Th.Clear();

            }
            timer1.Enabled = _bStart;
        }