By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,567 Members | 1,609 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,567 IT Pros & Developers. It's quick & easy.

"Not Responding" when reading and processing large file

P: n/a
I'm working on a win app that reads and processes each line of an ascii file
until the end of the file. Since the file's 1.6 million lines long, after a
while Windows displays the "Not Responding" although the application's
running fine. Is it possible to add anything that'll stop Windows from
displaying that?

Also, how would I be able to always have control of the form in case I want
to abort the process? Once it starts running, I lose control of the form.
I've heard of being able to use threads but I really didn't understand them.

Thank you.
Nov 15 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
L#
On Fri, 6 Feb 2004 09:22:41 -0500, "Jimbo" <None> wrote:
I'm working on a win app that reads and processes each line of an ascii file
until the end of the file. Since the file's 1.6 million lines long, after a
while Windows displays the "Not Responding" although the application's
running fine. Is it possible to add anything that'll stop Windows from
displaying that?

Also, how would I be able to always have control of the form in case I want
to abort the process? Once it starts running, I lose control of the form.
I've heard of being able to use threads but I really didn't understand them.

Thank you.


Start a new thread where the processing is done. Your main application
remains responsive that way. Have a look at the following URL for an
example:
http://www.vbcity.com/forums/faq.asp...&cat=Threading
--
Ludwig
mailto:ludwig_(nospamplease)stuyck@pandora(nospamp lease).be
Nov 15 '05 #2

P: n/a
it hungs because the window proc of your appl does not process messages sent
to it.

to fix that create thread which will be reading your large file and make
needed actions.

I advice you to read Richter's "advanced windows" and you will understand
what is "threads"..

--
Vladimir Scherbina,
Ukraine, Kiev.

"Jimbo" <None> wrote in message
news:uA**************@TK2MSFTNGP11.phx.gbl...
I'm working on a win app that reads and processes each line of an ascii file until the end of the file. Since the file's 1.6 million lines long, after a while Windows displays the "Not Responding" although the application's
running fine. Is it possible to add anything that'll stop Windows from
displaying that?

Also, how would I be able to always have control of the form in case I want to abort the process? Once it starts running, I lose control of the form.
I've heard of being able to use threads but I really didn't understand them.
Thank you.

Nov 15 '05 #3

P: n/a
To do this you really need to spawn the reading process of in another
thread., that way you can stop the thread at anytime.

"Jimbo" <None> wrote in message
news:uA**************@TK2MSFTNGP11.phx.gbl...
I'm working on a win app that reads and processes each line of an ascii file until the end of the file. Since the file's 1.6 million lines long, after a while Windows displays the "Not Responding" although the application's
running fine. Is it possible to add anything that'll stop Windows from
displaying that?

Also, how would I be able to always have control of the form in case I want to abort the process? Once it starts running, I lose control of the form.
I've heard of being able to use threads but I really didn't understand them.
Thank you.

Nov 15 '05 #4

P: n/a
See Chris Sells' article "Safe, Simple Threading in Windows Forms", here:

http://msdn.microsoft.com/library/de...ms06112002.asp
"Jimbo" <None> wrote in message
news:uA**************@TK2MSFTNGP11.phx.gbl...
I'm working on a win app that reads and processes each line of an ascii file until the end of the file. Since the file's 1.6 million lines long, after a while Windows displays the "Not Responding" although the application's
running fine. Is it possible to add anything that'll stop Windows from
displaying that?

Also, how would I be able to always have control of the form in case I want to abort the process? Once it starts running, I lose control of the form.
I've heard of being able to use threads but I really didn't understand them.
Thank you.

Nov 15 '05 #5

P: n/a
The class Application has a DoEvents() method. Take a look at that.

Jimbo wrote:
I'm working on a win app that reads and processes each line of an ascii file
until the end of the file. Since the file's 1.6 million lines long, after a
while Windows displays the "Not Responding" although the application's
running fine. Is it possible to add anything that'll stop Windows from
displaying that?

Also, how would I be able to always have control of the form in case I want
to abort the process? Once it starts running, I lose control of the form.
I've heard of being able to use threads but I really didn't understand them.

Thank you.


Nov 15 '05 #6

P: n/a
Don't waste the time & complexity of creating and monitoring an additional
thread.

Simply peridically call Application::DoEvents() in your file processing loop.

Antenna wrote:

The class Application has a DoEvents() method. Take a look at that.

Jimbo wrote:
I'm working on a win app that reads and processes each line of an ascii file
until the end of the file. Since the file's 1.6 million lines long, after a
while Windows displays the "Not Responding" although the application's
running fine. Is it possible to add anything that'll stop Windows from
displaying that?

Also, how would I be able to always have control of the form in case I want
to abort the process? Once it starts running, I lose control of the form.
I've heard of being able to use threads but I really didn't understand them.

Thank you.


--
Bret Pehrson
mailto:br**@infowest.com
NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl>>
Nov 15 '05 #7

P: n/a

Hi Jimbo,

Thank you for posting in the community!

Based on my understanding, your WinForm application did a large data
processing and the UI does not correspond. Also, you want a way that can
cancel the data processing in your application.

=============================================
To solve the UI corresponding problem, you can just call the
Application.DoEvents static method. If you call DoEvents in your code, your
application can handle the other events. Please refer it in MSDN document.

If you want to get more control over your data processing, I think
Well-designed multi-threading is a good option for you. Usually, you need
to use Main thread, work thead model. Main thread manipulate the UI, while
the work thread processing the data. In multi-threading application, there
are a lot of things you should be careful of. Such as synchronization,
deadlock etc.

I think the article in Philip's reply is a good one for Threading in
WinForm.
Also, you may get information on Fast and Responsive UI with Multiple
Threads at:
http://msdn.microsoft.com/msdnmag/is...g/default.aspx

============================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #8

P: n/a
J
On Fri, 06 Feb 2004 09:22:41 -0500, Jimbo wrote:
I'm working on a win app that reads and processes each line of an ascii file
until the end of the file. Since the file's 1.6 million lines long, after a
while Windows displays the "Not Responding" although the application's
running fine. Is it possible to add anything that'll stop Windows from
displaying that?

Also, how would I be able to always have control of the form in case I want
to abort the process? Once it starts running, I lose control of the form.
I've heard of being able to use threads but I really didn't understand them.

Thank you.

If your program needs to finish processing records before it can do
anything else then the Application.DoEvents is the way to go. Put it in
your loop and then when someone presses the cancel button the event will
fire and you can handle it.

If you program needs to do other things while the records are being
processed, then you need to put the file processing in another thread.

jerry

Nov 15 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.