首页 > 分享 > 线程Thread的一些使用方式

线程Thread的一些使用方式

最新推荐文章于 2024-08-15 19:01:20 发布

*八步赶蝉* 于 2018-12-10 14:30:26 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

1.直接看代码

using System;

using System.Threading;

using System.Timers;

using System.Windows.Forms;

namespace WindowsFormsApp13 {

public partial class Form1 : Form {

static SynchronizationContext synt;

public Form1() {

synt = SynchronizationContext.Current;

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e) {

Thread th = new Thread(new ParameterizedThreadStart(otherPrint));

th.Start();

}

private void otherPrint(object obj) {

Control.CheckForIllegalCrossThreadCalls = false;

this.result.Text = obj as String;

Control.CheckForIllegalCrossThreadCalls = true;

}

private void print() {

Control.CheckForIllegalCrossThreadCalls = false;

this.result.Text = "123";

Control.CheckForIllegalCrossThreadCalls = true;

}

}

}

Thread requestHandler = new Thread(

() => {

。。。

}

);

requestHandler.Start();

相关知识

线程Thread的一些使用方式
线程池提交任务的两种方式:execute与submit的区别
我之见
高并发之——死锁,死锁的四个必要条件以及处理策略
python 线程锁
国运:扮演李逍遥,队友东方镜
java多线程面试题整理及答案
龟兔赛跑(基于GUI与多线程实现)
解决多线程中资源竞争
Common Thread:2022年宠物行业报告

网址: 线程Thread的一些使用方式 https://m.mcbbbk.com/newsview332395.html

所属分类:萌宠日常
上一篇: 我有一只叫嘎嘎的宠物鸭
下一篇: 剑网3宠物愣头青鸭奇遇如何触发