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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Loading Problem

Loading Problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
8 Posts 4 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.
  • S Offline
    S Offline
    Sonu Kapoor
    wrote on last edited by
    #1

    HI Guys, i am using the CStdioFile ReadString() Function to read several files with the size of 350KB per File. Sometimes it takes to long to load the files and sometimes my app crashes. Is there any solution to save loading time ??? maybe any other function ? Best Regards Sonu

    J 1 Reply Last reply
    0
    • S Sonu Kapoor

      HI Guys, i am using the CStdioFile ReadString() Function to read several files with the size of 350KB per File. Sometimes it takes to long to load the files and sometimes my app crashes. Is there any solution to save loading time ??? maybe any other function ? Best Regards Sonu

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      ...and sometimes my app crashes. Is there any solution to save loading time ??? Your app crashing is a very likely sign that you've got a bug in your code --this may have to do with the poor performance you're obtaining, also. Could you post the piece of code in which you're using ReadString? This would help determine what's going on. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      S 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        ...and sometimes my app crashes. Is there any solution to save loading time ??? Your app crashing is a very likely sign that you've got a bug in your code --this may have to do with the poor performance you're obtaining, also. Could you post the piece of code in which you're using ReadString? This would help determine what's going on. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        S Offline
        S Offline
        Sonu Kapoor
        wrote on last edited by
        #3

        My app only crashes cause the files which i am loading are to large. If i try this with smaller files, everything works fine. So i need a solution for the loading Problem. strFile is just a csv file with the size of 350KB. CString sRow; CStdioFile inFile(strFileName, CFile::modeRead); while(inFile.ReadString(sRow) != FALSE) { // loading the String in a ListCtrl } inFile.Close(); you see i am not doing very much Best Regards Sonu

        L N J 3 Replies Last reply
        0
        • S Sonu Kapoor

          My app only crashes cause the files which i am loading are to large. If i try this with smaller files, everything works fine. So i need a solution for the loading Problem. strFile is just a csv file with the size of 350KB. CString sRow; CStdioFile inFile(strFileName, CFile::modeRead); while(inFile.ReadString(sRow) != FALSE) { // loading the String in a ListCtrl } inFile.Close(); you see i am not doing very much Best Regards Sonu

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          what about checking if "inFile" is valid? could be a problem as well

          1 Reply Last reply
          0
          • S Sonu Kapoor

            My app only crashes cause the files which i am loading are to large. If i try this with smaller files, everything works fine. So i need a solution for the loading Problem. strFile is just a csv file with the size of 350KB. CString sRow; CStdioFile inFile(strFileName, CFile::modeRead); while(inFile.ReadString(sRow) != FALSE) { // loading the String in a ListCtrl } inFile.Close(); you see i am not doing very much Best Regards Sonu

            N Offline
            N Offline
            Nish Nishant
            wrote on last edited by
            #5

            350 kb is surely not large enough to cause a crash. It must be something in your code. Carefully go through it step by step. Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

            S 1 Reply Last reply
            0
            • N Nish Nishant

              350 kb is surely not large enough to cause a crash. It must be something in your code. Carefully go through it step by step. Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

              S Offline
              S Offline
              Sonu Kapoor
              wrote on last edited by
              #6

              I know. I tryed the same with smaller files and everything works fine. NO CRASH Best Regards Sonu

              1 Reply Last reply
              0
              • S Sonu Kapoor

                My app only crashes cause the files which i am loading are to large. If i try this with smaller files, everything works fine. So i need a solution for the loading Problem. strFile is just a csv file with the size of 350KB. CString sRow; CStdioFile inFile(strFileName, CFile::modeRead); while(inFile.ReadString(sRow) != FALSE) { // loading the String in a ListCtrl } inFile.Close(); you see i am not doing very much Best Regards Sonu

                J Offline
                J Offline
                Joaquin M Lopez Munoz
                wrote on last edited by
                #7

                I don't think CStdioFile is having anything to do with the slowness of your code (you can verify this commenting out the code inside the loop and seeing if the app still goes slow). More probably it is the process of populating the CListCtrl that is causing your app to go slowmo. You can do two things to accelerate this process:

                • Rick York pointed out an interesting idea in a previous thread today that applies to your case. Use WM_SETREDRAW to prevent redrawing while you fill the list:

                  list.SendMessage(WM_SETREDRAW,(WPARAM)FALSE,0);
                  while(...){
                  ...
                  }
                  list.SendMessage(WM_SETREDRAW,(WPARAM)TRUE,0);

                • Make sure the styles LVS_SORTASCENDING and LVS_SORTDESCENDING are note set for the list control, to prevent sorting in the middle of the population process. Later, you can sort the data (if this is your wish) with CListCtl::SortItems.

                Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

                S 1 Reply Last reply
                0
                • J Joaquin M Lopez Munoz

                  I don't think CStdioFile is having anything to do with the slowness of your code (you can verify this commenting out the code inside the loop and seeing if the app still goes slow). More probably it is the process of populating the CListCtrl that is causing your app to go slowmo. You can do two things to accelerate this process:

                  • Rick York pointed out an interesting idea in a previous thread today that applies to your case. Use WM_SETREDRAW to prevent redrawing while you fill the list:

                    list.SendMessage(WM_SETREDRAW,(WPARAM)FALSE,0);
                    while(...){
                    ...
                    }
                    list.SendMessage(WM_SETREDRAW,(WPARAM)TRUE,0);

                  • Make sure the styles LVS_SORTASCENDING and LVS_SORTDESCENDING are note set for the list control, to prevent sorting in the middle of the population process. Later, you can sort the data (if this is your wish) with CListCtl::SortItems.

                  Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

                  S Offline
                  S Offline
                  Sonu Kapoor
                  wrote on last edited by
                  #8

                  Thanx I will try this. Maybe this can solve my Prob. Best Regards Sonu

                  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