473,395 Members | 1,863 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,395 software developers and data experts.

Here's an interesting one...

I have a program that seems to be locked up when it's chugging away. It
takes about 2-3 hours for its process to complete and normally runs between
2am-5am when nobody is in the office so it's not really a big deal. But
i've noticed that if a user was to click on the CloseBox, the Windows "This
Program is not responding" dialog pops up and gives the user the option to
stop the program. Is there a way to stop this from happening? I would
assume that if the program was really hung then I could ctrl-alt-delete it
and stop it that way...
Nov 21 '05 #1
6 1265

"Terry Olsen" <to******@hotmail.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
I have a program that seems to be locked up when it's chugging away. It
takes about 2-3 hours for its process to complete and normally runs between 2am-5am when nobody is in the office so it's not really a big deal. But
i've noticed that if a user was to click on the CloseBox, the Windows "This Program is not responding" dialog pops up and gives the user the option to
stop the program. Is there a way to stop this from happening?


You could put DoEvents in your program every few seconds or every x
iterations of a loop, or you could put the long-running process in a
separate thread (recommended). But unless you find some method of allowing
the UI to respond to external events (like a mouse click) there's no way to
prevent Window from doing the Not Responding thing.
Nov 21 '05 #2
Hi Terry,

Jeff's correct, but you can 'disable' the close (X) option on the window.
Here's how:
set up a boolean at the class level
dim closetest as boolean = true

In the form's closing event:
If closetest = True Then

e.Cancel = True

End If

Only chane closetest to false when a 'close' button is clicked, if you want
that.

HTH,

Bernie Yaeger

"Terry Olsen" <to******@hotmail.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
I have a program that seems to be locked up when it's chugging away. It
takes about 2-3 hours for its process to complete and normally runs between 2am-5am when nobody is in the office so it's not really a big deal. But
i've noticed that if a user was to click on the CloseBox, the Windows "This Program is not responding" dialog pops up and gives the user the option to
stop the program. Is there a way to stop this from happening? I would
assume that if the program was really hung then I could ctrl-alt-delete it
and stop it that way...

Nov 21 '05 #3
Yeah...I didn't think it mattered too much since I don't want anyone messing
with it anyway. I have the e.cancel = true during the process so I thought
that would stop anyone from shutting down the app...but then I noticed the
"Not Responding" anomoly...now I gotta go learn how to do threads...

"If it's not one thing, it's another. Either you can't get a job in
journalism, or Walter Cronkite thinks you cut the cheese in his
office." --Rosanne Rosannadanna
"Jeff Johnson" <i.***@enough.spam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

"Terry Olsen" <to******@hotmail.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
I have a program that seems to be locked up when it's chugging away. It
takes about 2-3 hours for its process to complete and normally runs between
2am-5am when nobody is in the office so it's not really a big deal. But
i've noticed that if a user was to click on the CloseBox, the Windows

"This
Program is not responding" dialog pops up and gives the user the option to stop the program. Is there a way to stop this from happening?


You could put DoEvents in your program every few seconds or every x
iterations of a loop, or you could put the long-running process in a
separate thread (recommended). But unless you find some method of allowing
the UI to respond to external events (like a mouse click) there's no way

to prevent Window from doing the Not Responding thing.

Nov 21 '05 #4
Threads are not that heard. There are many decent examples on the web about
them.

"Terry Olsen" <to******@hotmail.com> wrote in message
news:Op**************@TK2MSFTNGP10.phx.gbl...
Yeah...I didn't think it mattered too much since I don't want anyone messing with it anyway. I have the e.cancel = true during the process so I thought that would stop anyone from shutting down the app...but then I noticed the
"Not Responding" anomoly...now I gotta go learn how to do threads...

"If it's not one thing, it's another. Either you can't get a job in
journalism, or Walter Cronkite thinks you cut the cheese in his
office." --Rosanne Rosannadanna
"Jeff Johnson" <i.***@enough.spam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

"Terry Olsen" <to******@hotmail.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
I have a program that seems to be locked up when it's chugging away. It takes about 2-3 hours for its process to complete and normally runs between
2am-5am when nobody is in the office so it's not really a big deal. But i've noticed that if a user was to click on the CloseBox, the Windows

"This
Program is not responding" dialog pops up and gives the user the
option to stop the program. Is there a way to stop this from happening?


You could put DoEvents in your program every few seconds or every x
iterations of a loop, or you could put the long-running process in a
separate thread (recommended). But unless you find some method of allowing the UI to respond to external events (like a mouse click) there's no way

to
prevent Window from doing the Not Responding thing.


Nov 21 '05 #5

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Jeff's correct, but you can 'disable' the close (X) option on the window.
Here's how:
set up a boolean at the class level
dim closetest as boolean = true

In the form's closing event:
If closetest = True Then

e.Cancel = True

End If

Only chane closetest to false when a 'close' button is clicked, if you
want
that.


I don't see what good that will do. The problem is that the program is in a
long-running process and therefore isn't checking its message queue.
Therefore, the form's Close event won't be entered and your code will never
run. You've got to do something to yield to the CPU. Correct me if I'm
wrong....
Nov 21 '05 #6
Terry,
For an application that takes 2 to 3 hours without any user intervention, I
would consider creating a Console Application or a Windows Service instead
of a Windows Forms application!

A Windows Service by definition runs in the background so there is no UI
needed (or allowed) Windows Service doesn't even require a person logged
into the machine.

A Console Application runs in a console window (aka a "DOS Box").

I would consider using Performance Counters and/or an Event Log so my
"Process" (Windows Service or Console Application) could notify any user of
its progress. I might create a Windows Forms application that read these
Performance Counters and/or Event Logs & displayed the info in a "usable"
format, possible on remote machines! For a Console Application I would
consider simply using Console.Write to display progress messages to the
user.

The "This Program is not responding" is caused because your app did not
respond to any windows messages (Mouse Move) in a timely manner. This is
normally an indication of a hung app. DoEvents is one method of responding
to these windows messages in a timely manner. Threads is another. Both
require "special" code as your are mixing your "process" with the "UI". As
I suggested above I would literally separate the "process" from the "UI" by
making two programs...

Hope this helps
Jay
"Terry Olsen" <to******@hotmail.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
I have a program that seems to be locked up when it's chugging away. It
takes about 2-3 hours for its process to complete and normally runs between 2am-5am when nobody is in the office so it's not really a big deal. But
i've noticed that if a user was to click on the CloseBox, the Windows "This Program is not responding" dialog pops up and gives the user the option to
stop the program. Is there a way to stop this from happening? I would
assume that if the program was really hung then I could ctrl-alt-delete it
and stop it that way...

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bruno R. Dias | last post by:
Perhaps it would be interesting to program a virtual machine simulating an ancient computer (such as the pdp-7). Then, it would be rather interesting to code for it (porting gcc to it maybe?). I...
12
by: rawrite | last post by:
I am just finishing watching a documentary about Rod Serling. It was cool, but after 20 minutes it got boring and all I wanted to do is subscribe to Net Flix and rent the Twilight Zone episodes....
3
by: eBob.com | last post by:
Is there a namespace of interesting and important constants such as maximum length of a filename, maximum length of a path, maximum and minimum values which can be held by a Long (and other data...
11
by: Peter Fox | last post by:
A FAQ here goes something like "How can I get input from the middle of my form sent processed to PHP and the result returned to the page?" The standard answer is "You can't because PHP is server...
10
by: Kareem840 | last post by:
Hello. Unfortunately, I am in need of money to pay my credit card bills. If you could spare just $1, I would be grateful. I have a Paypal account. Kramer1260@hotmail.com. I swear this will go to my...
52
by: robert | last post by:
I'm very pleased to announce that Foundations of F#, the first book to be published on the F# programming, will finish its first printing run, tomorrow, Friday 25th May. It should reach any...
5
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
On Jun 3, 3:23 am, Jesse Ziser <d...@spam.diewrote: The relevant paragraph from the Standard is: ---- Begin Quote ---- The type declared is va_list which is an object type suitable for...
93
by: lorlarz | last post by:
Here, let's see what you JavaScript programmers have got Here is a place to share your large or larger full-blown JavaScript applications: real.comp.lang.js.apps (a new google group) Here is...
7
by: Mensanator | last post by:
Beacuse in 2.6, Python apparently has fixed a discrepency that existed in previous versions. In the IDLE that comes with 2.5, typing "as", to wit "import random as ran", the words "import" and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.