用CreateThread()创建线程
来源:互联网 发布:java8函数式编程 编辑:程序博客网 时间:2024/05/21 03:25
全过程例程如下:
- void __fastcall TForm1::btn_1Click(TObject *Sender)
- {
- if (hthread == NULL) { // 不存在则创建线程
- hthread = CreateThread(
- (LPSECURITY_ATTRIBUTES)0, // default security attributes
- 0, // use default stack size
- (LPTHREAD_START_ROUTINE)funcproc, // thread function
- NULL, // argument to thread function
- 0, // use default creation flags
- NULL); // returns the thread identifier
- } else {
- ResumeThread(hthread);
- }
- }
- //---------------------------------------------------------------------------
- DWORD WINAPI funcproc()// thread data
- {
- int i;
- while(true)
- {
- i++;
- Sleep(50);
- Form1-> lbl_1-> Caption = i;
- }
- }
- void __fastcall TForm1::btn_2Click(TObject *Sender)
- {
- SuspendThread(hthread);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormDestroy(TObject *Sender)
- {
- TerminateThread(hthread, (DWORD)0);
- CloseHandle(hthread);
- hthread = NULL;
- }
- 用CreateThread()创建线程
- -用哪个创建线程CreateThread还是_beginthread
- 使用CreateThread创建线程
- 创建线程 - CreateThread
- CreateThread函数--创建线程
- 线程创建函数CreateThread
- CreateThread创建线程函数
- -创建线程的函数CreateThread
- 避免使用CreateThread 创建线程
- _beginthread和CreateThread 创建线程
- 使用CreateThread函数创建线程
- 创建一个线程用哪个好?--CreateThread._beginthread.AfxBeginThread比较
- 为什么创建线程不用 CreateThread,而用 __beginthreadex
- CreateThread()线程创建函数,AfxBeginThread等
- CreateThread()线程创建函数,AfxBeginThread等
- CreateThread创建线程传递结构体参数
- CreateThread和AfxBeginThread创建线程实例
- 运行库 与 createthread 线程创建问题
- VC下dll程序的调试
- c# 一个有用的汉字转拼音类
- JS日历,很好看的一个JS日历
- Linux操作系统Ubuntu的apt命令学习
- SelectionList取值问题
- 用CreateThread()创建线程
- 推动企业发展:SOA与云计算相结合
- Delphi 6 Internal Error URW3537
- jfreechart学习心得(与大家分享)
- C# 3.0设计模式
- 为Trac安装基于Web表单登录验证界面的插件
- struts架构:结合struts和hibernate谈J2EE架构的数据表示
- 软件人员素质要求
- 搜索引擎行业的羊群效应