HOWTO CPU intensive task without make GUI not responding?

How to make a CPU intensive task without make GUI not responding?
For example, i want to show the user a progress animation during the
intensive task,
but this animation is blocked until the task has finished...
Thanks


0
mandelbort (11)
1/12/2004 4:28:59 PM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
829 Views

Similar Articles

[PageSpeed] 20

On Mon, 12 Jan 2004 16:28:59 GMT, "michele" <mandelbort@oggiweb.com>
wrote:

>How to make a CPU intensive task without make GUI not responding?
>For example, i want to show the user a progress animation during the
>intensive task,
>but this animation is blocked until the task has finished...
>Thanks
>

Run the task in a low priority thread. 


Steve
-- 
EasyNN-plus. The easy way to build neural networks.
Build networks from numeric, text and image files.
http://www.easynn.com
0
steve (110)
1/12/2004 4:45:06 PM
The simplest way to do this is to periodically run a message loop with in
your CPU intensive task.  By doing this you will let the system handle any
drawing message that are waiting to be processed, that includes any paint
messages, and button clicks (for example a cancel button).

void CMyWnd::MessageLoop()
{
MSG Msg;

      while (PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
      {
         if (!PreTranslateMessage(&Msg))
         {
            TranslateMessage(&Msg);
            DispatchMessage(&Msg);
         }
      }
}

void CMyWnd::DoCalculation()
{
    m_Progress.SetPos(0);
    m_Exit = FALSE;
    for (int i = 0; i < 100000 && !m_Exit;i++)
    {
        //do something
        m_Progress.StepIt();
        MessageLoop();
    }
}

void CMyWnd::OnCancel()
{
    m_Exit = TRUE;
}


Ali R.

"michele" <mandelbort@oggiweb.com> wrote in message
news:fXzMb.245651$vO5.10164310@twister1.libero.it...
> How to make a CPU intensive task without make GUI not responding?
> For example, i want to show the user a progress animation during the
> intensive task,
> but this animation is blocked until the task has finished...
> Thanks
>
>


0
nospam7515 (2086)
1/12/2004 5:00:12 PM
No other method? :(

<steve@tropheus.demon.co.uk> ha scritto nel messaggio
news:dgj500hjn268pm11hufm9dukbivivlj936@4ax.com...
> On Mon, 12 Jan 2004 16:28:59 GMT, "michele" <mandelbort@oggiweb.com>
> wrote:
>
> >How to make a CPU intensive task without make GUI not responding?
> >For example, i want to show the user a progress animation during the
> >intensive task,
> >but this animation is blocked until the task has finished...
> >Thanks
> >
>
> Run the task in a low priority thread.
>
>
> Steve
> --
> EasyNN-plus. The easy way to build neural networks.
> Build networks from numeric, text and image files.
> http://www.easynn.com


0
mandelbort (11)
1/12/2004 5:04:55 PM
Thanks for the reply :)
"Ali R." <nospam@nospam.com> ha scritto nel messaggio
news:woAMb.7583$MS3.6802@newssvr22.news.prodigy.com...
> The simplest way to do this is to periodically run a message loop with in
> your CPU intensive task.  By doing this you will let the system handle any
> drawing message that are waiting to be processed, that includes any paint
> messages, and button clicks (for example a cancel button).
>
> void CMyWnd::MessageLoop()
> {
> MSG Msg;
>
>       while (PeekMessage(&Msg,NULL,0,0,PM_REMOVE))
>       {
>          if (!PreTranslateMessage(&Msg))
>          {
>             TranslateMessage(&Msg);
>             DispatchMessage(&Msg);
>          }
>       }
> }
>
> void CMyWnd::DoCalculation()
> {
>     m_Progress.SetPos(0);
>     m_Exit = FALSE;
>     for (int i = 0; i < 100000 && !m_Exit;i++)
>     {
>         //do something
>         m_Progress.StepIt();
>         MessageLoop();
>     }
> }
>
> void CMyWnd::OnCancel()
> {
>     m_Exit = TRUE;
> }
>
>
> Ali R.
>
> "michele" <mandelbort@oggiweb.com> wrote in message
> news:fXzMb.245651$vO5.10164310@twister1.libero.it...
> > How to make a CPU intensive task without make GUI not responding?
> > For example, i want to show the user a progress animation during the
> > intensive task,
> > but this animation is blocked until the task has finished...
> > Thanks
> >
> >
>
>


0
mandelbort (11)
1/12/2004 5:08:24 PM
>How to make a CPU intensive task without make GUI not responding?
>For example, i want to show the user a progress animation during the
>intensive task,
>but this animation is blocked until the task has finished...

Are you using the standard Windows animation control (CAnimateCtrl)? I
thought that ran in a separate thread and did not interfere much with
your main thread.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
0
davidl (419)
1/12/2004 5:24:58 PM
Yes, actually i'm using the CAnimateCtrl, but in future might display an
animated gif...
"David Lowndes" <davidl@mvps.org> ha scritto nel messaggio
news:e0m5001fkob73ei9cl18alfuogh39uk7ro@4ax.com...
> >How to make a CPU intensive task without make GUI not responding?
> >For example, i want to show the user a progress animation during the
> >intensive task,
> >but this animation is blocked until the task has finished...
>
> Are you using the standard Windows animation control (CAnimateCtrl)? I
> thought that ran in a separate thread and did not interfere much with
> your main thread.
>
> Dave
> --
> MVP VC++ FAQ: http://www.mvps.org/vcfaq


0
mandelbort (11)
1/12/2004 5:32:28 PM
>Yes, actually i'm using the CAnimateCtrl, but in future might display an
>animated gif...

OK, so have you tried running the intensive task as a separate
(worker) thread?

Dave
-- 
MVP VC++ FAQ: http://www.mvps.org/vcfaq
0
davidl (419)
1/12/2004 7:24:47 PM
Run the task in a separate thread. Post messages to the main GUI thread to update the
progress information. See my essay on worker threads on my MVP Tips site.
					joe

On Mon, 12 Jan 2004 16:28:59 GMT, "michele" <mandelbort@oggiweb.com> wrote:

>How to make a CPU intensive task without make GUI not responding?
>For example, i want to show the user a progress animation during the
>intensive task,
>but this animation is blocked until the task has finished...
>Thanks
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15977)
1/12/2004 10:12:20 PM
Reply:

Similar Artilces:

How do I print without borders when creating a brochure
When I creat a brochure in Publisher there is a border around it. How do I eliminate it so that the pictures print to the edge? Jomo wrote: > When I creat a brochure in Publisher there is a border around it. How > do I eliminate it so that the pictures print to the edge? ==================================== Do you have a printer that can print to the edge? The following article may be worth a look: "How to find the maximum print area of your printer" http://ed.mvps.org/Static.aspx?=Publisher/horidiag -- John Inzer MS-MVP Digital Media Experience Notice ...

Trying to use Outlook Tasks
Please help me! Recently, at my job, we switched from using Lotus Organizer, to Microsoft Office Outlook 2003 (SP2). I really like it, overall, but I’m having a lot of trouble with the “Tasks” portion of it. Under the “Current View” of “Simple List,” I typed in about 30 Tasks that I need to get done. I didn’t specify a category then, so they all went under the category of “none.” By right clicking on the “Categories: (none) (30 items),” and selecting “Categories,” “Master Category List,” I was able to type in the categories that I wanted to use. When I clicked “Ok,” the cat...

CRM tasks synchronization
Can a CRM user create tasks in CRM for someone else and have it synchronize into Outlook for that other person? I've enabled the synchronization from the Outlook client and my own tasks are synchronizing but tasks for others are not. Thanks in advance, Dawn On Feb 21, 3:04 pm, TSIDawn <TSID...@discussions.microsoft.com> wrote: > Can a CRM user create tasks in CRM for someone else and have it synchroni= ze > into Outlook for that other person? I've enabled the synchronization from > the Outlook client and my own tasks are synchronizing but tasks for others > are...

Howto create textbox like in powerpoint
Hi Could someone tell me how to create powerpoint type textboxes? Are they windowless rich edit controls? Thanks Sachin They are rich edit control, but they have a window, they are owned by the window that they are being displayed on. AliR. "sachinkundu" <sachinkundu@gmail.com> wrote in message news:1170062520.486641.43880@m58g2000cwm.googlegroups.com... > Hi > > Could someone tell me how to create powerpoint type textboxes? Are > they windowless rich edit controls? > > Thanks > Sachin > > They are rich edit control, but they have a wind...

Task Scheduler
I'm not sure where to post this question. Will start here and if it's not here that I should post it, please tell me. My problem is this: when I open Task Scheduler, I get 53 pop-up error messages that various scheduled tasks no longer exist, and to get them back click on refresh. When I click on refresh, I get the same pop-up that it no longer exists. I identified all the folders that have the pop-up error messages, checked in c:\Windows\System32\Tasks\Microsoft\Windows and then opened one of the folders that's generating the error message and verified that the ...

User Form
This one must be simple. I just cant figure it out. SeaparkJohn has suggested using a User Form instead of a dialog shee for a menu system. I have created the User Form, But now I need to write a macro linked t a command button to make it appear, and dissapear. What is the code to do this? Thanks for your help. Celtic_Avenge -- Celtic_Avenge ----------------------------------------------------------------------- Celtic_Avenger's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1410 View this thread: http://www.excelforum.com/showthread.php?threadid=26801 So...

Smtp Authentication
Hi all I'm an IBM Domino administrator.But i have to fix an exchange 2003 server in these days.The problem is; the exchange server was full of spam yesterday because of open relay, i deleted all the spam.Now i want to make an smtp authentication setting on the exchange server. the schema is as that: 1 MS 2003 server (domain controller) with exchange 2003 installed (all fixpacks are included) (192.168.0.1).15 clients (winXP+Outlook 2000/XP/2003 mixed). network adress is 192.168.0.0/24 all the computers access to internet by a dsl router (192.168.0.254), using 192.168.0.1 as DNS server...

Workflow Tasks
Hi Could someone please assist me with the following: We would like a task to be assigned to specific users at 08:00 am. Each user would have 9 hours to complete this task and if this task is not completed then the manager should receive an email notifying him of the incomplete task. I attempted to do this in workflow however I was unsuccessful. This task needs to reference a specific task and be automatically assigned to the users at 08:00 every morning. ANy ideas? Thanks Hi Mark, If you are interested we can offer a custom solution for your requirement. Please drop a email to ...

CPU 100%
Several weeks ago, I did a clean install of Office 2003 Pro over a clean install of Windows XP Home on a machine with an AMD 2400+ and 512 megs of RAM. While tracking down strange behavior, I noticed that Outlook sometimes jumps to near 100% CPU usage and stays there. It happens when I send a message, when I delete a message and periodically at other times for no apparent reason - perhaps tied to inactivity. Clicking on 'receive messages' does not trigger the problem. It is similar to the redline problem earlier this year with some machines after installing Office 2000 SR-3. ...

Error 0x80040216 when inserting tasks through SDK
I am inserting tasks through SDK and when I have inserted 35 tasks my system throws the error below on the SOAPException.InnerText. 0x80040216 An unexpected error occurred. Platform What can I do? -- Microsoft Business Solutions Certified Professional–Microsoft CRM Applications Professional Microsoft Business Solutions Certified Professional–Microsoft CRM Customization ...

HDD ID / CPU ID
This is a multi-part message in MIME format. ------=_NextPart_000_0050_01C4F89C.6B520320 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi! All, 1.. How can I excess the Hard drive ID and the CPU ID. Any reference = to the related APIs would be appreciated. 2.. How do I detect the booting drive on Windows? Not everybody has it = named "C:\". Hence the querry. warm regards, - Divya Rathore www.ryze.com/go/divyarathore ------=_NextPart_000_0050_01C4F89C.6B520320 Content-Type: text/html; charset="iso-8859-1" Conte...

HOWTO Force landscape printing with CPrintDialog.
HOWTO Force landscape printing with CPrintDialog. Please help, I have the following code I want to FORCE to print in landscape after the CPrintDialog finishes. This solution must not touch the CWinApp's "m_hDevMode" data member. This solution must only do something to the DC returned from the CPrintDialog, and it must override any possible orientation settings the user may have change while they were inside CPrintDialog. : CPrintDialog CPrintDialog_Temp(FALSE); if (CPrintDialog_Temp.DoModal() == IDOK) { // Do something here to FORCE the print out to be landscape ...

assign the resource text1 a value in the tasks text 4 field...
I've been able to get the task text1 data to = the resource usage view text4 at the resource level....not the actual assignment level. any help with the procedure to set resource task1 = to tasks text4 would be greatly appreciated. thanks E In article <EE20CB14-ED35-4BC2-9BB2-B8E0E39DC7B9@microsoft.com>, Elvis <Elvis@discussions.microsoft.com> wrote: > I've been able to get the task text1 data to = the resource usage view text4 > at the resource level....not the actual assignment level. > > any help with the procedure to set resource tas...

CPU Speed or Cache, which is better?
We are trying to decide which is better for our Exchange 2007 servers: 2.66 QuadCore with 1MB cache per core (roughly $960) or 1.86 QuadCore with 2MB cache per core (roughly $819) Also, we are trying to figure out which is better for Exchange 2007: 1 Quad-core kit or 2 Dual-core kits Any ideas? These are for backend servers. These are beefy I know. but we add mailboxes to our servers every year and never lose them (mailbox for life policy). -- Regards, Blake Whitney GC Email Manager GC Email Manager <GCEmailManager@discussions.microsoft.com> wrote: >We are trying to deci...

outlook is not emailing assigned task
task assigned in my outlook is not being emailed to recipients. none of my email accounts could send mail from the task menu. Bummer. -- Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. ALWAYS post your Outlook version. How to ask a question: http://support.microsoft.com/KB/555375 After furious head scratching, Uturn asked: | task assigned in my outlook is not being emailed to recipients. none | of my email accounts could send mail from the task menu. ...

DLL Howto
Hello everyone, I would like to fill in people who have not made MFC dlls my experiences making them, and how to make DLL creation extremely simple. First you want to create a MFC extension dll, which is important because this specific type of DLL will allow you to export functions and classes without any confusing code. After that, implement any classes to the dll and when the class is being declared include the AFX_EXT_CLASS macro. For instance class CModifyTransaction : public CDialog would become... class AFX_EXT_CLASS CModifyTransaction : public CDialog after that is added any dll ...

Sharing calendars without Exchange
We are a small office of 4 running Outlook XP without an Exchange server. Is there any way we can share our calendars? Take a look here, it may help: http://www.slipstick.com/outlook/share.htm --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, Norah asked: | We are a small office of 4 running Outlook XP without an | Exchange server. Is there any way we can share o...

Outlook keeps making itself Default
Hi, Everytime I start Outlook it takes over as default for email and addresses even though I have that option unchecked in outlook, and in IE I set OE Express as default, yet each time I launch outlook it takes over as Default, any ideas TIA Wayne ...

outlook 2000 spiking CPU
Win2Kpro. When Outlook 2000 is running the CPU usage jumps up to 100%. Shutting it down returns the system to "normal." ...

Outlook / Tasks
This is a multi-part message in MIME format. ------=_NextPart_000_0011_01C47ADE.F251EC00 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, Is it possible, by the means of coding, that when I open Outlook, I = could have my tasks open automatically in a new window? If it is, I'd appreciate any resources as I don't know coding myself. Thank you, Jay ------=_NextPart_000_0011_01C47ADE.F251EC00 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-...

HOWTO: Protecting a Document???
Hi... I'm still using Office XP (Word 2002). I'm just about finished making a FORM document which I plan to turn into a template (.DOT). I've turned on the "Forms Protect"... which moves the user around the "protected text" but I also want to disable anyone from changing the original .DOT itself (this will be a standard form and don't need some smart-ass altering something that I'm, ultimately, responsible for). I'm still GOOGLE'g but... how can I allow a user to OPEN this file to enter data/check boxes into the FORM FIELDS......

Making sub reports invesible
I have this repot that has 3 text boxes Summer Brochure Winter Brochure Skiing Brochure Which will have -1 or 0 depending if true or false I also have 3 sub reports for each brochure How can i set it to make the a subreport invesiable if one of the brochures is false 0 Thanks Simon. I think you mean you have 3 subforms... one for each of the Brochure types. Do you mean that if SummerBrochure is False, hide the SummerBrochure subform... and the same for each of the Brochure types. In the OnFormat event of the report section that contains the brochure subforms... Su...

100%CPU with inetinfo.exe
Hi (AD2000, W2K, Exchange 2000 SP3) since this morning, process inetinfo.exe takes 100% CPU. the mail system is still running and delivering email but very slowly. there are no errors loggued anywhere. it's exactly the same problem as this : http://www.experts-exchange.com/Networking/Email_Groupware/Exchange_Server/Q_21683466.html what can i do ? thanks If you are running SMTP antivirus on your server try stopping it and see the utilization. Also you noticed high CPU utilization this morning please go thru your application and system event logs. It might give you some clue ...

Word Task Pane...
Whenever I have opened up Word, the Task Pane has always appeared and now it has disappeared. I have to click on View, and click on Task Pane for it to appear. Also, in Tools, Options, View, under Show, there is a check by Startup Task Pane. I am wondering why it is now never there when opening up from the beginning? Some add-ins will prevent it from appearing. See http://word.mvps.org/FAQs/Customization/ShowTaskPane.htm. Note that you need only run the Task Pane Controller macro once (to change the Registry setting); then you should uninstall the Task Pane Controller add...

Exchange Certificate HowTo
I am looking for a howto on implementing Verisign Certificates into the Exchange environment. Currently all of our users have Digital ID's from Verisign to encrypt e-mail messages. We attempted to install these certificates into Outlook 2003 with no luck. When sending to user while attempting to encrypt it says that we are unable to send encrypted mail to this user even though we have his/her digital ID locally. My question involves how to get the server to recognize the certificates or how to enable exchange to see the certificates. We are using WIn2003 SBS with Exchange 2003 and on the c...