CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #1
    Join Date
    Jun 2012
    Posts
    2

    How to slow the program down?

    I was trying the code below:
    Code:
    --------------------------------------------------
    void CChildView::OnMatlabTry3()
    {
    	// TODO: Add your command handler code here
    	CDC *pDC = GetDC();
    	CString i_String("");
    	for (int i = 0; i < 10000000 ; i++)
    	{
    		i_String.Format("%d", i);
    		pDC->TextOutA(300, 100, i_String);
    		pDC->MoveTo(0, 0);
    		pDC->LineTo(100, 300+i/10000);
    	}
    	pDC->DeleteDC();
    }
    --------------------------------------------------
    It is the Event Handler to the menu. When I run this part, the program is running, but it consume 40% of the CPU resource and I can't move the program window. So is there any function that I can use to slow the program down?
    Last edited by Marc G; July 2nd, 2012 at 01:33 AM. Reason: Added code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured