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#
  4. C# Windows Application seems to be not responding!

C# Windows Application seems to be not responding!

Scheduled Pinned Locked Moved C#
helpcsharpsysadminwindows-adminperformance
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.
  • A Offline
    A Offline
    Adeel Chaudhry
    wrote on last edited by
    #1

    Hello! Hope you all are doing great! We were having clumsy sort of issue! details are as follows: - We have c# windows application, which processes the data(simple text file, huge in size aprox. 40Gb). - Doing so, it doesnot show any sort of items on the form, it looks as if its hanged/not responding - Application consists of 1 form, which contains few performance indicators, few labels, few progress bars. - But in reality it is working and processing the data(checked from the task manager, and also the output file is generated very accuratly). - From start till end application utilizes 100% of the cpu. - If we try to run any other program even notepad, system hangs n we have to restart it! We are using Windows Server 2003, any sort of help, idea, suggestion, question will definitly be appreciated!:)! Thanks in advance! Adeel --

    G R A 3 Replies Last reply
    0
    • A Adeel Chaudhry

      Hello! Hope you all are doing great! We were having clumsy sort of issue! details are as follows: - We have c# windows application, which processes the data(simple text file, huge in size aprox. 40Gb). - Doing so, it doesnot show any sort of items on the form, it looks as if its hanged/not responding - Application consists of 1 form, which contains few performance indicators, few labels, few progress bars. - But in reality it is working and processing the data(checked from the task manager, and also the output file is generated very accuratly). - From start till end application utilizes 100% of the cpu. - If we try to run any other program even notepad, system hangs n we have to restart it! We are using Windows Server 2003, any sort of help, idea, suggestion, question will definitly be appreciated!:)! Thanks in advance! Adeel --

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      Processing 40GB file is very expensive for computer. The time it takes will depend on the computer you are running it on. Also use threads in your application

      A 1 Reply Last reply
      0
      • A Adeel Chaudhry

        Hello! Hope you all are doing great! We were having clumsy sort of issue! details are as follows: - We have c# windows application, which processes the data(simple text file, huge in size aprox. 40Gb). - Doing so, it doesnot show any sort of items on the form, it looks as if its hanged/not responding - Application consists of 1 form, which contains few performance indicators, few labels, few progress bars. - But in reality it is working and processing the data(checked from the task manager, and also the output file is generated very accuratly). - From start till end application utilizes 100% of the cpu. - If we try to run any other program even notepad, system hangs n we have to restart it! We are using Windows Server 2003, any sort of help, idea, suggestion, question will definitly be appreciated!:)! Thanks in advance! Adeel --

        R Offline
        R Offline
        Rob Graham
        wrote on last edited by
        #3

        It sounds as if you are doing your file processing on the UI thread, and you are not allowing any time to any other threads. 1> do the data processing on a worker thread, use 2> do a small chunk of processing then call Thread.Sleep(ms) to allow other things to run for a few ms, that way you don't hog 100% of the CPU.

        A 2 Replies Last reply
        0
        • G Giorgi Dalakishvili

          Processing 40GB file is very expensive for computer. The time it takes will depend on the computer you are running it on. Also use threads in your application

          A Offline
          A Offline
          Adeel Chaudhry
          wrote on last edited by
          #4

          Very right :), but why it is not showing up the items(labels, progress bars...etc), and how can we make it show them and also do the processing as well!!? The machine specs are 2.8E GHz HT Processor, 1 GB RAM, 160 GB SATA-II Drive! Any suggestions how shall we implement threads, like processing in seperate thread? is this what you mean? and wil it solve the issue:(?

          G 1 Reply Last reply
          0
          • R Rob Graham

            It sounds as if you are doing your file processing on the UI thread, and you are not allowing any time to any other threads. 1> do the data processing on a worker thread, use 2> do a small chunk of processing then call Thread.Sleep(ms) to allow other things to run for a few ms, that way you don't hog 100% of the CPU.

            A Offline
            A Offline
            Adeel Chaudhry
            wrote on last edited by
            #5

            Ok, will surely give it a try, and will let know of the result!:) Thanks both of you!:)!

            1 Reply Last reply
            0
            • A Adeel Chaudhry

              Very right :), but why it is not showing up the items(labels, progress bars...etc), and how can we make it show them and also do the processing as well!!? The machine specs are 2.8E GHz HT Processor, 1 GB RAM, 160 GB SATA-II Drive! Any suggestions how shall we implement threads, like processing in seperate thread? is this what you mean? and wil it solve the issue:(?

              G Offline
              G Offline
              Giorgi Dalakishvili
              wrote on last edited by
              #6

              Have a look at Backgroundworker component. It has got a good example:)

              1 Reply Last reply
              0
              • R Rob Graham

                It sounds as if you are doing your file processing on the UI thread, and you are not allowing any time to any other threads. 1> do the data processing on a worker thread, use 2> do a small chunk of processing then call Thread.Sleep(ms) to allow other things to run for a few ms, that way you don't hog 100% of the CPU.

                A Offline
                A Offline
                Adeel Chaudhry
                wrote on last edited by
                #7

                :)! Thanks Rob, shifted the processing part on the workerthread, and without calling Thread.Sleep, its working great!!!:)!

                1 Reply Last reply
                0
                • A Adeel Chaudhry

                  Hello! Hope you all are doing great! We were having clumsy sort of issue! details are as follows: - We have c# windows application, which processes the data(simple text file, huge in size aprox. 40Gb). - Doing so, it doesnot show any sort of items on the form, it looks as if its hanged/not responding - Application consists of 1 form, which contains few performance indicators, few labels, few progress bars. - But in reality it is working and processing the data(checked from the task manager, and also the output file is generated very accuratly). - From start till end application utilizes 100% of the cpu. - If we try to run any other program even notepad, system hangs n we have to restart it! We are using Windows Server 2003, any sort of help, idea, suggestion, question will definitly be appreciated!:)! Thanks in advance! Adeel --

                  A Offline
                  A Offline
                  AFSEKI
                  wrote on last edited by
                  #8

                  Create a BackgroundThread for processing the file. If you are storing the data read from the file in memory, make sure it does not consume too much ( Check the return value of FileStream.Read which returns the number of bytes read and add them to a "long totalBytesRead = 0;" variable each time as "totalBytesRead += bytesRead" and check: if(totalBytesRead <= (1024*1024*50)) // more than 50 MB { ReadMore(); } else { ProcessCurrentData(); CleanMemory(); // reset the read buffer forexample } And don't forget Application.DoEvents(); method ;) Hope this helps...

                  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