码迷,mamicode.com
首页 > 其他好文 > 详细

进度条的优先级比对

时间:2014-05-12 21:56:14      阅读:504      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   tar   

一共设置了三个优先级,第一个正常优先级,第二个低优先级,第三个高优先级

运行效果:bubuko.com,布布扣

代码:

bubuko.com,布布扣
 1 void CTestProgressDlg::OnBnClickedBtnStart()
 2 {
 3     // TODO: 在此添加控件通知处理程序代码
 4     // 创建线程
 5     m_hThread1 = CreateThread(NULL, 0, Thread1, this, CREATE_SUSPENDED, NULL);
 6     m_hThread2 = CreateThread(NULL, 0, Thread2, this, CREATE_SUSPENDED, NULL);
 7     m_hThread3 = CreateThread(NULL, 0, Thread3, this, CREATE_SUSPENDED, NULL);
 8     // 设置线程优先级
 9     SetThreadPriority(m_hThread1, THREAD_PRIORITY_NORMAL);
10     SetThreadPriority(m_hThread2, THREAD_PRIORITY_LOWEST);
11     SetThreadPriority(m_hThread3, THREAD_PRIORITY_HIGHEST);
12     // 唤醒线程
13     ResumeThread(m_hThread1);
14     ResumeThread(m_hThread2);
15     ResumeThread(m_hThread3);
16 }
17 DWORD WINAPI CTestProgressDlg::Thread1(LPVOID lpParam)
18 {
19     CTestProgressDlg *pDlg = (CTestProgressDlg*)lpParam;
20     for(int i = 0;i < 10000;i++)
21     {
22         pDlg->m_progress1.SetPos(i);
23     }
24     return 0;
25 }
26 DWORD WINAPI CTestProgressDlg::Thread2(LPVOID lpParam)
27 {
28     CTestProgressDlg *pDlg = (CTestProgressDlg*)lpParam;
29     for(int i = 0;i < 10000;i++)
30     {
31         pDlg->m_progress2.SetPos(i);
32     }
33     return 0;
34 }
35 DWORD WINAPI CTestProgressDlg::Thread3(LPVOID lpParam)
36 {
37     CTestProgressDlg *pDlg = (CTestProgressDlg*)lpParam;
38     for(int i = 0;i < 10000;i++)
39     {
40         pDlg->m_progress3.SetPos(i);
41     }
42     return 0;
43 }
44 
45 void CTestProgressDlg::OnBnClickedBtnPause()
46 {
47     // TODO: 在此添加控件通知处理程序代码
48     SuspendThread(m_hThread1);
49     SuspendThread(m_hThread2);
50     SuspendThread(m_hThread3);
51 }
52 
53 void CTestProgressDlg::OnBnClickedBtnContinue()
54 {
55     // TODO: 在此添加控件通知处理程序代码
56     ResumeThread(m_hThread1);
57     ResumeThread(m_hThread2);
58     ResumeThread(m_hThread3);
59 }
bubuko.com,布布扣

 

进度条的优先级比对,布布扣,bubuko.com

进度条的优先级比对

标签:style   blog   class   code   java   tar   

原文地址:http://www.cnblogs.com/lit10050528/p/3722027.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!