C# Windows Application seems to be not responding!
-
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 --
-
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 --
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
-
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 --
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.
-
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
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:(?
-
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.
Ok, will surely give it a try, and will let know of the result!:) Thanks both of you!:)!
-
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:(?
Have a look at Backgroundworker component. It has got a good example:)
-
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.
:)! Thanks Rob, shifted the processing part on the workerthread, and without calling Thread.Sleep, its working great!!!:)!
-
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 --
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...