跨线程的得到系统时间
来源:互联网 发布:seo在线培训哪家好 编辑:程序博客网 时间:2024/05/23 14:17
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Threading;namespace Clock{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void DelegateFunc(string time) { //if (this.InvokeRequired) //判断当前运行的线程是不是与窗体主线程是同一个线程。 //{ // this.Invoke(new Action<string>(DelegateFunc), time); //} //else //{ // textBox_Clock.Text = DateTime.Now.ToString(); //} this.Invoke((Action)(() => { textBox_Clock.Text = DateTime.Now.ToString(); })); } public void ThreadFunc() //定义线程函数 { while (true) { DelegateFunc(DateTime.Now.ToString()); //用代理的形式实现功能函数 } } private void btn_Start_Click(object sender, EventArgs e) { //Thread thread = new Thread(new ThreadStart(ThreadFunc)); //thread.IsBackground = true; //thread.Start(); Action act = new Action(ThreadFunc); act.BeginInvoke(null, null); //WaitCallback wcb = new WaitCallback(ThreadFunc); //ThreadPool.QueueUserWorkItem(wcb, null); } private void btn_Stop_Click(object sender, EventArgs e) { MessageBox.Show("我不知道该怎么结束"); } }}
0 0
- 跨线程的得到系统时间
- 得到系统当前的时间
- 如何得到系统的时间 CTime
- File 得到系统的修改时间
- 得到系统时间的几个方法
- 得到系统时间
- 简单得到系统时间
- java得到系统时间
- linux 得到系统时间
- 如何得到系统时间
- studio得到系统时间
- jsp 得到当前系统时间
- c中得到系统时间
- Android开发得到系统时间
- iOS 得到系统当前时间
- JAVA得到当前系统时间
- android中得到系统时间
- asp.net如何得到用户端的系统时间
- servlet必知细节(三)-- DefaultServlet
- Radiobutton样式修改
- HTTP与内容压缩:
- 放弃WebView,使用Crosswalk做富文本编辑器
- 追逐自己的梦想----------辅助制作第三十七课:物品购买实现
- 跨线程的得到系统时间
- 【Java二十周年】回忆我与Java的点点滴滴
- android 布局优化几个控件
- c++ 内存布局
- C语言的谜题
- CMake 实例学习(三) 构建共享库
- 五招教你面试谈出满意薪资!
- 你有“金矿”,开采吧
- LAN、WAN、WLAN、VLAN和VPN的区别