Exemplo n.º 1
0
        public T blockedGet <T>()
        {
            lock (this)
            {
                if (_value != null)
                {
                    return((T)_value);
                }
                try
                {
#pragma warning disable 618
                    _thread.Suspend();
#pragma warning restore 618
                }
                catch (InterruptedException e)
                {
                    throw new LuaException(e.Message);
                }
            }

            lock (this)
            {
                return((T)_value);
            }
        }
Exemplo n.º 2
0
 public static void performChatMsg(byte type, string dest, string msg)
 {
     Byte[] data = formatChatMsg(type, dest, msg);
     while (stream.DataAvailable)
     {
     }                               //wait until nothing to read
     listenerThread.Suspend();
     stream.WriteByte(type);
     writeWrappedMsg(stream, data);
     //return (stream.DataAvailable && stream.ReadByte() == 1);
     listenerThread.Resume();
 }
Exemplo n.º 3
0
        private void SendFile()
        {
            while (SIGN_STREAMSETUP)
            {
                sendfilestream = new FileStream(SENDFILENAME, FileMode.Open, FileAccess.Read, FileShare.None);
                byte[] buffer = new byte[sendfilestream.Length];

                byte[] bytefileLength = System.Text.Encoding.Default.GetBytes(sendfilestream.Length.ToString());
                stream.Write(bytefileLength, 0, bytefileLength.Length);
                while (true)
                {
                    try
                    {
                        int length = sendfilestream.Read(buffer, 0, buffer.Length);
                        if (length == 0)
                        {
                            sendfilestream.Close();
                            sendfilestream.Dispose();
#if DEBUG
                            MessageBox.Show("Send a file");
#endif
                            // 发送文件完毕,进程挂起。
                            sendfileThread.Suspend();
                            break;
                        }
                        stream.Write(buffer, 0, length);
                    }
                    catch (IOException ex)
                    {
                        MessageBox.Show(ex.ToString());
                        break;
                    }
                }
            }
        }
Exemplo n.º 4
0
 public static void Suspend()
 {
     if (IsAlive)
     {
         ControlationThread.Suspend();
     }
 }
Exemplo n.º 5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;

            if (t.ThreadState == System.Threading.ThreadState.Running)
            {
                t.Suspend();
            }

            try
            {
                pictureBox5.Image = (Bitmap)Rslt.Clone();
                pictureBox5.Image.Save("Result-" + Si + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                Si++;
            }
            catch (Exception ex)
            {
            }
            if (t.ThreadState == System.Threading.ThreadState.Suspended)
            {
                t.Resume();
            }
            this.Text = s;
            if (s == "DONE")
            {
                return;
            }
            timer1.Enabled = true;
        }
Exemplo n.º 6
0
 private void buttonPause_Click(object sender, EventArgs e)
 {
     pictureState.Image    = global::TesterAutomation_Dashboard.Properties.Resources.red;
     labelState_Value.Text = "Not Running";
     MonitorThread.Suspend();
     buttonPause.Enabled  = false;
     buttonResume.Enabled = true;
 }
Exemplo n.º 7
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         if (button2.Text.ToLower() == "pause")
         {
             thread2.Suspend();
             button2.Text = "Resume";
         }
         else if (button2.Text.ToLower() == "resume")
         {
             thread2.Resume();
             button2.Text = "Pause";
         }
     }
     catch { }
 }
Exemplo n.º 8
0
 private void buttonStop_Click(object sender, EventArgs e)
 {
     m_mapThread.Suspend();
     buttonRun.Enabled  = true;
     buttonRun.Visible  = true;
     buttonStop.Enabled = false;
     buttonStop.Visible = false;
 }
Exemplo n.º 9
0
 private void button4_Click(object sender, EventArgs e)
 {
     button1.Enabled = true;
     button2.Enabled = true;
     button4.Enabled = false;
     button3.Enabled = true;
     t.Suspend();
 }
Exemplo n.º 10
0
        private void btnPause_Click(object sender, EventArgs e)
        {
            setPauseButtons();

            // Suspendovnje niti kad se klikne dugme Pause
            //
            topThread.Suspend();
            bottomThread.Suspend();

            stopwatch1.Stop();
            stopwatch2.Stop();
        }
Exemplo n.º 11
0
 private void TFLanRequisicao_FormClosing(object sender, FormClosingEventArgs e)
 {
     Utils.ShapeGrid.SaveShape(this, gRequisicao);
     Utils.ShapeGrid.SaveShape(this, gItens);
     Properties.Settings.Default.tempo = tempoNotificacao.Value;
     Properties.Settings.Default.Save();
     try
     {
         thNovaReq.Suspend();
         thNovaReq = null;
     }
     catch { }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Обработчик события изменения размера буфера изображений
 /// </summary>
 public void BitmapCache_SizeChanged()
 {
     if (jpegBuffer.isFull)
     {
         VDBReaderSingle.Suspend();
     }
     else
     {
         if (VDBReaderSingle.ThreadState == System.Threading.ThreadState.Suspended)
         {
             VDBReaderSingle.Resume();
         }
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// 发送数据的线程函数。
 /// </summary>
 private void SendDataLoop()
 {
     while (SIGN_STREAMSETUP)
     {
         byte[] commandbuffer = System.Text.Encoding.ASCII.GetBytes("command");
         stream.Write(commandbuffer, 0, commandbuffer.Length);
         byte[] buffer = System.Text.Encoding.Default.GetBytes(DATATOSEND);
         if (buffer.Length == 0)
         {
             sendDataThread.Suspend();
         }
         try
         {
             stream.Write(buffer, 0, buffer.Length);
         }
         catch (IOException ex)
         {
             MessageBox.Show(ex.ToString());
             break;
         }
         sendDataThread.Suspend();
     }
 }
Exemplo n.º 14
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (!bCheck)
     {
         bCheck = true;
         //일시정지된 스레드 다시 시작
         thMain.Resume();
         button1.Text = "Internet Connect Check Start";
     }
     else
     {
         bCheck = false;
         //스레드 일시정지
         thMain.Suspend();
         button1.Text = "Internet Connect Check Stop";
     }
 }
Exemplo n.º 15
0
        private void btStart_Click(object sender, RoutedEventArgs e)
        {
            if (!StartClicked)
            {
                if (VideoPlayng == null && VDBReaderSingle == null)
                {
                    RealTimeInitialise(cbVideoArchive.Text);
                }

                try
                {
                    if (VideoPlayng.ThreadState == System.Threading.ThreadState.Stopped || VideoPlayng.ThreadState == System.Threading.ThreadState.Unstarted)
                    {
                        fstreamVDICount = 0;
                        VideoPlayng.Start();
                    }
                    else
                    {
                        VideoPlayng.Resume();
                    }
                    StartClicked    = true;
                    btStart.Content = "Пауза";
                }
                catch (NullReferenceException NE)
                {
                    if (VideoPlayng == null)
                    {
                        MessageBox.Show("Откройте файл");
                    }
                }
                catch (System.Threading.ThreadStateException ThreadStateExeption) { }
            }
            else
            {
                try
                {
                    VideoPlayng.Suspend();
                    StartClicked    = false;
                    btStart.Content = "Старт";
                }
                catch (NullReferenceException NE) { }
            }
        }
Exemplo n.º 16
0
 private bool mataThread()
 {
     try
     {
         if (m_bThreadRunning)
         {
             m_thrEnviaEmail.Suspend();
             m_bThreadRunning = false;
             m_formFEnviandoEmail.m_gbFields.Text  = "Cancelado";
             m_formFEnviandoEmail.m_lMensagem.Text = "Envio de E-Mail cancelado.";
             return(false);
         }
     }
     catch (Exception err)
     {
         Object erro = err;
         m_cls_ter_tratadorErro.trataErro(ref erro);
     }
     return(true);
 }
        public IPosition GetMouseDoubleChickedRealPosition()
        {
            System.Threading.Thread currentThread            = System.Threading.Thread.CurrentThread;
            Position_Point          mouseChickedRealPosition = null;

            this.BeginInvoke(new dShow(MessageBox.Show), new object[] { "please double chick on the screen." });

            MouseDoubleClick += delegate(object sender, MouseEventArgs e)
            {
                mouseChickedRealPosition = new Position_Point();
                mouseChickedRealPosition.SetX(ConvertMouseXToRealX(e.X));
                mouseChickedRealPosition.SetY(ConvertMouseYToRealY(e.Y));

                if ((currentThread.ThreadState & System.Threading.ThreadState.Suspended) == System.Threading.ThreadState.Suspended)
                {
                    currentThread.Resume();
                }
            };

            currentThread.Suspend();
            return(mouseChickedRealPosition);
        }
Exemplo n.º 18
0
 public IPosition GetMouseChickedRealPosition()
 {
     if (this.InvokeRequired)
     {
         IPosition chickedPosition             = null;
         System.Threading.Thread currentThread = System.Threading.Thread.CurrentThread;
         MouseCheckRealPosition += delegate(IPosition position)
         {
             chickedPosition = position;
             if ((currentThread.ThreadState & System.Threading.ThreadState.Suspended) == System.Threading.ThreadState.Suspended)
             {
                 currentThread.Resume();
             }
         };
         currentThread.Suspend();
         MouseCheckRealPosition = null;
         return(chickedPosition);
     }
     else
     {
         IAsyncResult result = new dGetMouseChickedRealPosition(GetMouseChickedRealPosition).BeginInvoke(null, null);
         return((IPosition)this.EndInvoke(result));
     }
 }
Exemplo n.º 19
0
 protected override void OnClosing(CancelEventArgs e)
 {
     if (thread != null)
     {
         thread.Suspend();
         if (MessageBox.Show("업데이트 중입니다. 종료하시겠습니까?", "경고",
                             System.Windows.Forms.MessageBoxButtons.YesNo,
                             System.Windows.Forms.MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             thread.Resume();
             thread.Abort();
             thread.Join();
             thread            = null;
             e.Cancel          = false;
             this.DialogResult = DialogResult.Cancel;
         }
         else
         {
             e.Cancel = true;
             thread.Resume();
         }
     }
     base.OnClosing(e);
 }
Exemplo n.º 20
0
        /// <summary>
        /// 发送文件的线程函数。
        /// </summary>
        private void SendFileLoop()
        {
            while (SIGN_STREAMSETUP)
            {
                sendfilestream = new FileStream(SENDFILEADDRESS, FileMode.Open, FileAccess.Read, FileShare.None);
                byte[] buffer = new byte[sendfilestream.Length];

                string metaOfFile = "picture" + "//" + SENDFILENAME + "//" +
                                    sendfilestream.Length.ToString();
                byte[] byte_metaOfFile = System.Text.Encoding.ASCII.GetBytes(metaOfFile);
                stream.Write(byte_metaOfFile, 0, byte_metaOfFile.Length);

                while (true)
                {
                    try
                    {
                        int length = sendfilestream.Read(buffer, 0, buffer.Length);
                        if (length == 0)
                        {
                            sendfilestream.Close();
                            sendfilestream.Dispose();

                            // 发送文件完毕,进程挂起。
                            sendfileThread.Suspend();
                            break;
                        }
                        stream.Write(buffer, 0, length);
                    }
                    catch (IOException ex)
                    {
                        MessageBox.Show(ex.ToString());
                        break;
                    }
                }
            }
        }
Exemplo n.º 21
0
 protected override void OnStop()
 {
     thread.Suspend();
 }
Exemplo n.º 22
0
 protected override void OnPause()
 {
     Log("RECM Paused", EventLogEntryType.Information);
     monitorThread.Suspend();
     base.OnPause();
 }
Exemplo n.º 23
0
 private void button1_Click(object sender, EventArgs e)
 {
     t2.Suspend();
 }
        public IPosition GetMouseDoubleChickedNearestPositionInCurrentPositionSet(IPositionSet currentPositionSet)
        {
            M2M_NN m2m_NN = new M2M_NN();

            m2m_NN.PreProcess(currentPositionSet);

            layersPaintedControl.state_PainterForm_MouseDown = LayersPaintedControl.State_PainterForm_MouseDown.onDaggle;
            ResetEventHandler();
            //layersPainterForm.state_PainterForm_MouseDown = LayersPainterForm.State_PainterForm_MouseDown.Other;
            IPosition nearestPoint = new Position_Connected_Edit(0, 0);
            PositionSetEdit_ImplementByICollectionTemplate positionSetEdit_ImplementByICollectionTemplate = new PositionSetEdit_ImplementByICollectionTemplate();

            positionSetEdit_ImplementByICollectionTemplate.AddPosition(nearestPoint);
            Layer_PositionSet_Square layer = new Layer_PositionSet_Square(positionSetEdit_ImplementByICollectionTemplate);

            MouseMovedRealPosition = delegate(IPosition position)
            {
                positionSetEdit_ImplementByICollectionTemplate.RemovePosition(nearestPoint);
                nearestPoint = m2m_NN.NearestNeighbor(position);
                positionSetEdit_ImplementByICollectionTemplate.AddPosition(nearestPoint);
                layer.SpringLayerRepresentationChangedEvent(layer);
                layersPaintedControl.Invalidate();
            };

            layer.VisibleInOptDlg = false;
            layer.Active          = true;
            layer.Name            = "Edited Figure";
            layer.SquareFrameDrawer.RectangleRadiusWidth = 8;
            layer.SquareFrameDrawer.LineWidth            = 1;
            layer.SquareFrameDrawer.LineColor            = Color.Red;
            layer.CenterPointCoordinate.Visible          = true;
            layer.CenterPointCoordinate.CoordinateFont   = new Font(layer.CenterPointCoordinate.CoordinateFont, FontStyle.Bold);


            System.Threading.Thread currentThread            = System.Threading.Thread.CurrentThread;
            Position_Connected_Edit mouseChickedRealPosition = null;
            IPosition nearestPositionInCurrentPositionSet    = null;

            this.BeginInvoke(new dShow(MessageBox.Show), new object[] { "please double chick on the screen." });

            MouseDoubleChickOnLayersPaintedControl += delegate(object sender, MouseEventArgs e)
            {
                mouseChickedRealPosition = new Position_Connected_Edit();
                mouseChickedRealPosition.SetX(layersPaintedControl.ConvertMouseXToRealX(e.X));
                mouseChickedRealPosition.SetY(layersPaintedControl.ConvertMouseYToRealY(e.Y));

                nearestPositionInCurrentPositionSet = m2m_NN.NearestNeighbor(mouseChickedRealPosition);

                if ((currentThread.ThreadState & System.Threading.ThreadState.Suspended) == System.Threading.ThreadState.Suspended)
                {
                    currentThread.Resume();
                }
            };

            if (currentLayer != null)
            {
                layers.Remove(currentLayer);
            }
            currentLayer = layer;
            layers.Add(layer);

            currentThread.Suspend();
            MouseDoubleChickOnLayersPaintedControl = null;
            return(nearestPositionInCurrentPositionSet);
        }
Exemplo n.º 25
0
        private void btnSnapshotSwitch_Click(object sender, EventArgs e)
        {
            if (!isStarted)
            {
                int count = 0;
                if (threadSnapshot == null || threadSnapshot.ThreadState == System.Threading.ThreadState.Stopped)
                {
                    threadSnapshot = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                    {
                        while (true)
                        {
                            if (isStoped)
                            {
                                break;
                            }
                            else
                            {
                                this.Invoke(new Action(() =>
                                {
                                    Snapshot();
                                    this.SnapshotCount.Text = "" + (++count);
                                }));
                                System.Threading.Thread.Sleep((int)this.SnapshotInterval.Value);
                                Application.DoEvents();
                            }
                        }
                    }));
                }

                if (threadSnapshot == null)
                {
                    throw new Exception("This thread snapshot is null.");
                }

                if (threadSnapshot.ThreadState == System.Threading.ThreadState.Suspended)
                {
                    threadSnapshot.Resume();
                }

                if (threadSnapshot.ThreadState == System.Threading.ThreadState.Unstarted)
                {
                    threadSnapshot.Start();
                }

                this.btnSnapshotSwitch.Text = "End";
                isStarted = true;
            }
            else
            {
                if (threadSnapshot == null)
                {
                    return;
                }

                threadSnapshot.Suspend();

                isStarted = false;

                this.btnSnapshotSwitch.Text = "Begin";
            }
        }
Exemplo n.º 26
0
 public void Suspend()
 {
     threadField.Suspend();
 }
Exemplo n.º 27
0
 public void SuspendTh()
 {
     t.Suspend();//挂起线程
     this.btnTh.Text = "继续";
 }