473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

"Not Responding" when reading and processing large file

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
8 12756
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
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
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
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
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
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Basil Fenix | last post by:
I check data from a text file with a mdb Database using a progressbar and changing the Caption by % to indicate to the user what is happening.The file is large and takes quite a while. The problem...
289
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could...
72
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and...
6
by: Botak | last post by:
Hi, I wrote an app under vb.net to calculate huge data from MS Sql server. Whenever this app is running, I could not do other work. Or else, the app will become "not responding" but actually it is...
60
by: Dave | last post by:
I'm never quite sure whether to use "this." or not when referring to fields or properties in the same class. It obviously works just fine without it but sometimes I wonder if using this....
10
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
5
by: yeoj13 | last post by:
Hello, I have a db2load script I'm using to populate a large table. Ideally, my target table is required to have "Not Null" constraints on a number of different columns. I've noticed a ...
1
by: Rklawton | last post by:
I've got some CPU intensive VBA code that works just fine. However, I get the application "not responding" message in my task manager while it executes. When this happens (after a few seconds...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.