c++ boost--------------boost::progress_timer小试。

 1 //---------------------------------------------------------------------------

 2 

 3 #include <vcl.h>

 4 #pragma hdrstop

 5 

 6 #include "Unit4.h"

 7 #include <boost/progress.hpp>

 8 #include <sstream>

 9 using  namespace std;

10 //---------------------------------------------------------------------------

11 #pragma package(smart_init)

12 #pragma resource "*.dfm"

13 TForm4 *Form4;

14 //---------------------------------------------------------------------------

15 __fastcall TForm4::TForm4(TComponent* Owner)

16     : TForm(Owner)

17 {

18 }

19 

20 void test_timer(std::stringstream& ss)

21 {

22     ss.clear();

23     boost::progress_timer t(ss);

24 

25     {

26         //boost::progress_timer t1(ss);

27         Sleep(1000);

28         //Form4->Memo1->Lines->Add((AnsiString)"1--"+ss.str().c_str());

29     }

30 

31     {

32         //boost::progress_timer t2(ss);

33         //boost::progress_timer t(ss);

34         Sleep(2001);

35         //Form4->Memo1->Lines->Add((AnsiString)"2--"+ss.str().c_str());

36     }

37 

38     {

39         //boost::progress_timer t3(ss);

40         //boost::progress_timer t(ss);

41         Sleep(3002);

42         //Form4->Memo1->Lines->Add((AnsiString)"3--"+ss.str().c_str());

43     }

44 }

45 

46 

47 //---------------------------------------------------------------------------

48 void __fastcall TForm4::Button1Click(TObject *Sender)

49 {

50     std::stringstream ss;

51      test_timer(ss);

52     this->Memo1->Lines->Add(ss.str().c_str());

53 }

54 //---------------------------------------------------------------------------

 

你可能感兴趣的:(progress)