当前位置: 首页>>代码示例>>C#>>正文


C# System.Threading.Thread.Start方法代码示例

本文整理汇总了C#中System.Threading.Thread.Start方法的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.Thread.Start方法的具体用法?C# System.Threading.Thread.Start怎么用?C# System.Threading.Thread.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.Thread的用法示例。


在下文中一共展示了System.Threading.Thread.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainForm

        public MainForm()
        {
            InitializeComponent();
            try
            {
                foreach (IPAddress ip in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
                {
                    if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    {
                        localIP = ip;
                        break;
                    }
                }
                udpListen = new UDPListen(new IPEndPoint(localIP, localPort));
                System.Threading.ThreadStart threadStartListen;

                threadStartListen = new System.Threading.ThreadStart(udpListen.open);
                udpListen.msgReceiptEvent += new msgReceiptHandler(listen_msgReceiptEvent);
                threadListen = new System.Threading.Thread(threadStartListen);
                threadListen.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:uufrost,项目名称:SatPwr,代码行数:26,代码来源:MainForm.cs

示例2: Start

        public void Start(Action run)
        {
            Debug.Assert(!isRunning);

            thread = new System.Threading.Thread(new System.Threading.ThreadStart(run));
            thread.Start();
        }
开发者ID:hardlydifficult,项目名称:HardlyBot,代码行数:7,代码来源:Threadable.cs

示例3: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         System.Threading.ThreadStart ts = delegate
         {
             CLKsFATXLib.Streams.Reader OR = Original.Reader();
             CLKsFATXLib.Streams.Writer D = Destination.Writer();
             OR.BaseStream.Position = 0;
             D.BaseStream.Position = 0;
             for (long i = 0; i < Original.Length; i += 0x6000)
             {
                 D.Write(OR.ReadBytes(0x6000));
                 progressBar1.Invoke((MethodInvoker)delegate
                 {
                     try
                     {
                         progressBar1.Maximum = (int)(Original.Length >> 4);
                         progressBar1.Value = (int)(((i >> 8) < 0) ? 0 : i >> 4);
                     }
                     catch { }
                 });
             }
             OR.Close();
             D.Close();
         };
         System.Threading.Thread t = new System.Threading.Thread(ts);
         t.Start();
     }
     catch (Exception x) { MessageBox.Show(x.Message); }
 }
开发者ID:709881059,项目名称:party-buffalo,代码行数:31,代码来源:Clone.cs

示例4: runUpload

 public static void runUpload( )
 {
     if (Properties.Settings.Default.firstrun)
         return;
     NameValueCollection postdata = new NameValueCollection();
     postdata.Add("u", Properties.Settings.Default.username);
     postdata.Add("p", Properties.Settings.Default.password);
     if (!Clipboard.ContainsImage() && !Clipboard.ContainsText()) {
         nscrot.balloonText("No image or URL in clipboard!", 2);
         return;
     }
     if (!Clipboard.ContainsText()) {
         Image scrt = Clipboard.GetImage();
         System.Threading.Thread upld = new System.Threading.Thread(( ) =>
         {
             nscrot.uploadScreenshot(postdata, scrt);
         });
         upld.SetApartmentState(System.Threading.ApartmentState.STA);
         upld.Start();
     } else {
         string lURL = Clipboard.GetText();
         System.Threading.Thread shrt = new System.Threading.Thread(( ) =>
         {
             nscrot.shorten(lURL);
         });
         shrt.SetApartmentState(System.Threading.ApartmentState.STA);
         shrt.Start();
     }
 }
开发者ID:Maffsie,项目名称:NetScrot,代码行数:29,代码来源:Program.cs

示例5: StartHostAndClient_SimpleSyncMethodSyncCallWithAsync_Success

        public async void StartHostAndClient_SimpleSyncMethodSyncCallWithAsync_Success()
        {
            bool @continue = false;
            var thread = new System.Threading.Thread(() =>
            {
                using (var host = new WcfExampleServiceHost("localhost:10000"))
                {
                    host.Start();
                    @continue = true;
                    while (@continue)
                    {
                        System.Threading.Thread.Sleep(10);
                    }
                    host.Close();
                }
            });
            thread.Start();

            while ([email protected])
            {
                System.Threading.Thread.Sleep(10);
            }

            var client = new WcfExampleServiceAsyncClient("localhost:10000");
            SimpleSyncMethodResponseModel responseSimpleSyncMethod = client.SimpleSyncMethod(new SimpleSyncMethodRequestModel { Message = "Hello World" });
            Assert.IsNotNull(responseSimpleSyncMethod);
            Assert.AreEqual("SimpleSyncMethod: Hello World", responseSimpleSyncMethod.Message);

            @continue = false;

            thread.Join();
        }
开发者ID:CasperWollesen,项目名称:CW.Samples,代码行数:32,代码来源:WcfExampleServiceUnitTests.cs

示例6: Start

        public void Start(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits)
        {
            if (!GetAvailablePorts().Contains(portName))
            {
                throw new Exception(string.Format("Unknown serial port: {0}", portName));
            }

            // Start the timer to empty the receive buffer (in case data smaller than MAX_RECEIVE_BUFFER is received)
            _bufferTimer = new Timer();
            _bufferTimer.Interval = BUFFER_TIMER_INTERVAL;
            _bufferTimer.Elapsed += _bufferTimer_Elapsed;
            _bufferTimer.Start();

            // Instantiate new serial port communication
            _serialPort = new SerialPort(portName, baudRate, parity, dataBits, stopBits);

            // Open serial port communication
            _serialPort.Open();

            // Check that it is actually open
            if (!_serialPort.IsOpen)
            {
                throw new Exception(string.Format("Could not open serial port: {0}", portName));
            }

            _serialPort.ReadTimeout = 100; // Milliseconds

            _readThread = new System.Threading.Thread(ReadThread);
            _readThreadRunning = true;
            _readThread.Start();
        }
开发者ID:whitestone-no,项目名称:open-serial-port-monitor,代码行数:31,代码来源:SerialReader.cs

示例7: DiscoverDynamicCategories

        public override int DiscoverDynamicCategories()
        {
            _thread = new System.Threading.Thread(new System.Threading.ThreadStart(ReadEPG));
            _thread.Start();
 
            Settings.Categories.Clear();
            RssLink cat = null;

            cat = new RssLink()
            {
                Name = "Channels",
                Other = "channels",
                Thumb = "http://arenavision.in/sites/default/files/FAVICON_AV2015.png",
                HasSubCategories = false
            };
            Settings.Categories.Add(cat);

            cat = new RssLink()
            {
                Name = "Agenda",
                Other = "agenda",
                Thumb = "http://arenavision.in/sites/default/files/FAVICON_AV2015.png",
                HasSubCategories = false
            };
            Settings.Categories.Add(cat);

            Settings.DynamicCategoriesDiscovered = true;
            return Settings.Categories.Count;
        }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:29,代码来源:ArenavisionUtil.cs

示例8: Run

        public void Run()
        {
            //if ((ElectronTicket_HPCQ_Getway == "") || (ElectronTicket_HPCQ_UserName == "") || (ElectronTicket_HPCQ_UserPassword == ""))
            //{
            //    log.Write("ElectronTicket_XGCQ Task 参数配置不完整.");

            //    return;
            //}

            // 已经启动
            if (State == 1)
            {
                return;
            }

            lock (this) // 确保临界区被一个 Thread 所占用
            {
                State = 1;

                gCount1 = 0;

                thread = new System.Threading.Thread(new System.Threading.ThreadStart(Do));
                thread.IsBackground = true;

                thread.Start();

                log.Write("ElectronTicket_XGCQ Task Start.");
            }
        }
开发者ID:ichari,项目名称:ichari,代码行数:29,代码来源:XGCQ.cs

示例9: Ajouter_Click

 private void Ajouter_Click(object sender, EventArgs e)
 {
     System.Threading.Thread monthread = new System.Threading.Thread(new System.Threading.ThreadStart(Ajout));
     monthread.Start();
     this.Close();
     LoadPerso();
 }
开发者ID:Otomo07,项目名称:test,代码行数:7,代码来源:AdminSup.cs

示例10: ActionWindowLoaded

        private async void ActionWindowLoaded(object sender, RoutedEventArgs e)
        {
            if (count == 0)
            {
                id = Properties.Settings.Default.UserID;
                //ClientNameTextBox.Text = id;
                Active = true;
                Thread = new System.Threading.Thread(() =>
                {
                    Connection = new HubConnection(Host);
                    Proxy = Connection.CreateHubProxy("SignalRMainHub");

                    Proxy.On<string, string>("addmessage", (name, message) => OnSendData(DateTime.Now.ToShortTimeString()+"    ["+ name + "]\t " + message));
                    Proxy.On("heartbeat", () => OnSendData("Recieved heartbeat <3"));
                    Proxy.On<HelloModel>("sendHelloObject", hello => OnSendData("Recieved sendHelloObject " + hello.Molly + " " + hello.Age));

                    Connection.Start();

                    while (Active)
                    {
                        System.Threading.Thread.Sleep(10);
                    }
                }) { IsBackground = true };
                
                Thread.Start();
                
                count++;
            }

        }
开发者ID:xomidar,项目名称:AcademyManagementSystem,代码行数:30,代码来源:ChatPage.xaml.cs

示例11: SendNonQuery

 protected void SendNonQuery(string stmt)
 {
     var pts = new System.Threading.ParameterizedThreadStart(_SendNonQuery);
     System.Threading.Thread t = new System.Threading.Thread(pts);
     t.Start(stmt);
     t.Join();
 }
开发者ID:MindFlavor,项目名称:BackupToUrlWithRotation,代码行数:7,代码来源:DBUtil.cs

示例12: reConnect

        public void reConnect()
        {
            clientSocket.Close();
            clientSocket = null;
            sendBuffer = new byte[1024];//Send buffer //c# automatic assigesd to 0     

            try
            {
                clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                System.Threading.Thread tt = new System.Threading.Thread(delegate()
                {
                    try
                    {
                        clientSocket.Connect(ip, port);
                    }
                    catch (Exception ee)
                    {
                        //MessageBox.Show(ee.Message + "\r\n From:" + this);
                    }
                });
                tt.Start();

            }
            catch (Exception e)
            {
                //MessageBox.Show(e.Message + "\r\n From:" + this);
            }
        }
开发者ID:Season02,项目名称:MK2.0,代码行数:29,代码来源:socket.cs

示例13: socket

        public byte[] sendBuffer = null;//Send buffer

        public socket(String ipAddress)
        {
            ip = ipAddress;
            sendBuffer = new byte[1024];//Send buffer //c# automatic assigesd to 0     
            try
            {
                //创建一个Socket
                clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                System.Threading.Thread tt = new System.Threading.Thread(delegate()
                {
                    //连接到指定服务器的指定端口
                    //方法参考:http://msdn.microsoft.com/zh-cn/library/system.net.sockets.socket.connect.aspx
                    try
                    {
                        clientSocket.Connect(ip, port);
                    }
                    catch(Exception ee)
                    {
                        MessageBox.Show(ee.Message);
                    }
                });
                tt.Start();
                
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "\r\n From:" + this);
            }

        }
开发者ID:Season02,项目名称:MK2.0,代码行数:33,代码来源:socket.cs

示例14: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            this.IsPostPanelExpand = true;
            this.IsFunctionPanelExpand = true;
            this.IsMessagePostPanelExpand = true;

            this.AuthPanel.OkButton.Click += new RoutedEventHandler(OkButton_Click);
            this.AuthPanel.PrevButton.Click += new RoutedEventHandler(PrevButton_Click);
            this.AuthPanel.NextButton.Click += new RoutedEventHandler(NextButton_Click);

            this.ReplyPanel.ReplyButton.Click += new RoutedEventHandler(ReplyPanelReplyButton_Click);
            this.ReplyPanel.CancelButton.Click += new RoutedEventHandler(ReplyPanelCancelButton_Click);

            #region Task Tray
            int ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
            int Screenheigth = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            int AppWidth = (int)this.Width;
            int AppHeight = (int)this.Height;
            Canvas.SetLeft(this, ScreenWidth - AppWidth);  //ScreenWidth / 2 - AppWidth / 2;
            Canvas.SetTop(this, Screenheigth - AppHeight); //Screenheigth / 2 - AppHeight / 2;
            this.StateChanged += new EventHandler(MainWindow_StateChanged);
            this.taskIcon = new System.Windows.Forms.NotifyIcon();
            this.taskIcon.Visible = true;
            this.taskIcon.Icon = Properties.Resources.YammyyIcon;
            this.taskIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(taskIcon_MouseClick);
            this.taskIcon.ContextMenu = new System.Windows.Forms.ContextMenu();
            System.Windows.Forms.MenuItem item = new System.Windows.Forms.MenuItem("&Exit", taskIconItemExit_Click);
            this.taskIcon.ContextMenu.MenuItems.Add(item);
            #endregion

            System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(InitialCheck));
            th.Start();
        }
开发者ID:changman,项目名称:yammyy,代码行数:35,代码来源:MainWindow.xaml.cs

示例15: EventNotifyClient

        public EventNotifyClient(string strIP,int port,bool bAutoRetry)
        {
            this.bAutoRetry = bAutoRetry;
            this.port = port;
            string[]ips=strIP.Split(new char[]{'.'});

            for(int i=0;i<4;i++)
                ipByte[i]=System.Convert.ToByte(ips[i]);

            //if (bAutoRetry)
            //{
                System.Threading.Thread th = new System.Threading.Thread(Connect_Task);
                th.Start();

            //}
            //else
            //{
            //    tcp = new System.Net.Sockets.TcpClient();

            //    tcp.Connect(new System.Net.IPAddress(ipByte), port);

            //    bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            //    connected = true;
            //    Console.WriteLine("NotifySerevr connected!");
            //    new System.Threading.Thread(ClientWork).Start();
            //}
        }
开发者ID:ufjl0683,项目名称:sshmc,代码行数:27,代码来源:EventNotifyClient.cs


注:本文中的System.Threading.Thread.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。