Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Multithreaded Single Document Multiple View Architecture

Multithreaded Single Document Multiple View Architecture

Scheduled Pinned Locked Moved C / C++ / MFC
designhelpannouncementc++graphics
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rand Althor
    wrote on last edited by
    #1

    Hi guys, I need an opinion regarding a problem I have. I'm an university student working for a company in New Zealand, developing an MFC application which communicates, through a serial port, to an external device. The application will then subsequently retrieve data, stores it in a document object, and update all views currently opened. There could be many views of the data, involving various line plots. I've written the first version of this application last year, and we found that the lineplot drawing can be very intensive, the User Interface becomes very slow to respond to user clicks, etc. I've looked at maximising the drawing calculations, but there's simply not much I can do to improve it further. The boss surely enough doesn't like this ^^ He wants some improvement made. At the moment, I'm thinking of creating a UI thread for each separate view. That is, everytime user wnats to open a new, say line plot, a new UI thread will be spawned off and in turn a new frame and view will be created to display the data. The problem comes about because data will be continually updated, so the thread must have access to the actual document object, and the mainframe menu must continually be adjusted to account for the different view. For example, when the view is a line plot, certain toolbars must appear, which can be quite different from when a table is displayed. I've been looking all over the net and MSDN for information, but it seems that there is a great reluctance to tackle the multithreaded SingleDocument-Multiple View approach. Nasty, they say =P. I was wondering if nybody can give me some pointers to creating a multithreaded SD/MV framework. Thank you very muc:cool:h. I would greatly appreciate any help anybody can give me.

    R 1 Reply Last reply
    0
    • R Rand Althor

      Hi guys, I need an opinion regarding a problem I have. I'm an university student working for a company in New Zealand, developing an MFC application which communicates, through a serial port, to an external device. The application will then subsequently retrieve data, stores it in a document object, and update all views currently opened. There could be many views of the data, involving various line plots. I've written the first version of this application last year, and we found that the lineplot drawing can be very intensive, the User Interface becomes very slow to respond to user clicks, etc. I've looked at maximising the drawing calculations, but there's simply not much I can do to improve it further. The boss surely enough doesn't like this ^^ He wants some improvement made. At the moment, I'm thinking of creating a UI thread for each separate view. That is, everytime user wnats to open a new, say line plot, a new UI thread will be spawned off and in turn a new frame and view will be created to display the data. The problem comes about because data will be continually updated, so the thread must have access to the actual document object, and the mainframe menu must continually be adjusted to account for the different view. For example, when the view is a line plot, certain toolbars must appear, which can be quite different from when a table is displayed. I've been looking all over the net and MSDN for information, but it seems that there is a great reluctance to tackle the multithreaded SingleDocument-Multiple View approach. Nasty, they say =P. I was wondering if nybody can give me some pointers to creating a multithreaded SD/MV framework. Thank you very muc:cool:h. I would greatly appreciate any help anybody can give me.

      R Offline
      R Offline
      Rand Althor
      wrote on last edited by
      #2

      Okay, No replies.. either nobody have any idea, or my post is just plain silly. REgardless, I've been corresponding with Michal Mecinski, the author of a really good article about MSDI applications, which can be found at http://www.codeguru.com/doc_view/msdi.html[^]. This is what he's got to say about my problem: Hello, I've been searching the MSDN for some info and din't find much about multithreaded doc/view applications. The only solution I found was to go trough the MFC source code and experiment with various solutions. The application you described sounds more complicated to me. I guess the whole document and view classes would have to be completely rewritten. But I have a different idea. You may create a worker thread for each view, that draws the line plot on a bitmap in memory. The view would need to send a message to the working thread whenever the data is updated. You can copy the data for each thread or let the threads access the data in the document directly (using a semaphore of course). The working thread should actually have two bitmaps - one being displayed in the view (simple BitBlt) and one being drawn by the worker thread. After the plot is drawn you switch the bitmaps and post a message to the view to redraw itself. I think this is much simpler than using multiple UI threads. I used such solution once in an application that was drawing fractals and it worked perfectly. I hope this might help. Regards, Michal Mecinski Any comments, folks? :cool: Two Rivers!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups