Solved

UpdateAllViews - OnDraw Lags

Posted on 2006-11-02
1
288 Views
Last Modified: 2013-11-20
Hi Experts,

Developing an application for grabbing data off a bus and displaying it (similiar to Ethereal but for a different protocol). Have the code below in my Doc class. The problem is when I do an updateallviews - my OnDraw() function is putting up a lot of text up on the screen (using a BitMap to avoid flicker) but theres tons of data coming in on the bus and the delay from the time I receive the data to the time it gets drawn on the screen is a few seconds.

Is there an obvious reason why the lag/delay is occuring - is there a simple solution to speed up the time from when I receive data to get it drawn up on the screen?

void MyDoc::OnCommandStop()
{
     stop_recv_flag = 1;
}

void MyDoc::DoEvents()
{  
     MSG msg;  
     while ( ::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE ) )
     {  
          ::TranslateMessage(&msg);
          ::DispatchMessage(&msg);
     }
}

void MyDoc::OnCommandRun()
{
     while(!stop_recv_flag)
     {
          status = read_bus (data);
          if (status == GOTDATA)
          {
               UpdateAllViews(NULL);    
          }  
          DoEvents();              
     }

     stop_recv_flag = 0;
}

Thanks!
0
Comment
Question by:DizZzM
1 Comment
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 500 total points
ID: 17864301
May be you can have a worker thread to receive / read bus data and from your thread function you may send message to your main application to update other views / information to display..

-MAHESH
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 22
ADO Memory leak with DELPHI 2007 37 157
Line meaning 9 77
Annoying "thing" blocks my view 4 54
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now