コード例 #1
0
 /// <summary>
 /// 创建线程来执行某个方法(无返回值)
 /// </summary>
 public static void TryRunByThread(Action fun, bool skipException = true)
 {
     System.Threading.ThreadStart start  = new Threading.ThreadStart(fun);
     System.Threading.Thread      thread = new Threading.Thread(start);
     thread.IsBackground = true;
     if (skipException)
     {
         try
         {
             thread.Start();
         }
         catch { }
     }
     else
     {
         thread.Start();
     }
 }
コード例 #2
0
        public void SendMessageAsync(SmtpMessage msg, AsyncCallback cb)
        {
            _messageQueue.Add(1);
            SmtpClientSendMessageAsyncResult messageAsync = new SmtpClientSendMessageAsyncResult {
                CB = cb, Message = msg
            };

            Threading.Thread thread = new Threading.Thread(SendMessageAsync_Thread);
            thread.Start(messageAsync);
        }
コード例 #3
0
        public void Start()
        {
            _device = Open();
            if (_device == null)
            {
                throw new Exception("Cannot open Ethernet interface");
            }

            _deviceMac = _device.Interface.MacAddress.GetAddressBytes();

            // filter to only bacnet packets
            _device.Filter = "ether proto 0x82";

            System.Threading.Thread th = new Threading.Thread(CaptureThread);
            th.IsBackground = true;
            th.Start();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: xuri02/Global
        public string SertchImageWithInfo(Bitmap _Sertchin, Bitmap _Sertchfor, out bool _R, out Point point, out TimeSpan _TimeSpan, ImageScanMethode imageScanMethode, int toleranz = 0, bool jointhread = true)
        {
            var __r        = false;
            var __TimeSpan = TimeSpan.MinValue;
            var Point      = new Point(0, 0);

            var t = new Threading.Thread(() => _Thread(_Sertchin, _Sertchfor, out __r, out Point, out __TimeSpan, imageScanMethode, toleranz));

            t.Start();
            if (jointhread)
            {
                t.Join();
            }
            _R        = __r;
            point     = Point;
            _TimeSpan = __TimeSpan;

            return($"Thread returned: {_R},  X={point.X}, Y={point.Y}, TimeSpan(Millisec)={__TimeSpan.Milliseconds}");
        }
コード例 #5
0
ファイル: SmtpClient.cs プロジェクト: HaKDMoDz/eStd
		public void SendMessageAsync(SmtpMessage msg, AsyncCallback cb)
		{
			_messageQueue.Add(1);
			SmtpClientSendMessageAsyncResult messageAsync = new SmtpClientSendMessageAsyncResult { CB = cb, Message = msg };

			Threading.Thread thread = new Threading.Thread(SendMessageAsync_Thread);
			thread.Start(messageAsync);
		}
コード例 #6
0
 private void Form1_Load(object sender, System.EventArgs e) {
     // Dim s As New InTheHand.Windows.Forms.SelectBluetoothDeviceDialog()
     // s.ForceAuthentication = True
     // s.ShowAuthenticated = True
     // s.ShowRemembered = True
     // s.ShowUnknown = True
     // s.ShowDialog()
     System.Threading.Thread t1;
     t1 = new Threading.Thread(new System.EventHandler(this.receiveLoop));
     t1.Start();
     btClient = new BluetoothClient();
     BluetoothDeviceInfo[] bdi = btClient.DiscoverDevices();
     cboDevices.DataSource = bdi;
     cboDevices.DisplayMember = "DeviceName";
 }
コード例 #7
0
    public void SendMessageAsync(SmtpMessage msg, AsyncCallback cb)
    {
      m_msg_queue.Add(1);
      SmtpClientSendMessageAsyncResult m_obj = new SmtpClientSendMessageAsyncResult();
      m_obj.cb = cb;
      m_obj.Message = msg;

      Threading.Thread m_thread = new Threading.Thread(SendMessageAsync_Thread);
      m_thread.Start(m_obj);
    }