Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1593
  • Last Modified:

VB.Net Application Intermittently Hanging

I have written an application in VB.Net using Visual Studio 2005 and deployed it on XP pc's with SQL 2005 backend. Occasionally when some individuals leave the application and probably PC  idle for a few minutes on  returning to it the application hangs. Additionally after trying to access the application the PC practically hangs until the application is terminated via task manager.  Common scenario is usually the user left application open but not doing anything.

Typical event log attached.

Any help appreciated.

Event Source: Application Hang
Event Category: (101)
Event ID: 1002
Date:  24/10/2008
Time:  13:25:25
User:  N/A
Computer: LAURA3
Description:
Hanging application Boris.exe, version 1.0.0.0, hang module hungapp, version 0.0.0.0, hang address 0x00000000.
 
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 41 70 70 6c 69 63 61 74   Applicat
0008: 69 6f 6e 20 48 61 6e 67   ion Hang
0010: 20 20 42 6f 72 69 73 2e     Boris.
0018: 65 78 65 20 31 2e 30 2e   exe 1.0.
0020: 30 2e 30 20 69 6e 20 68   0.0 in h
0028: 75 6e 67 61 70 70 20 30   ungapp 0
0030: 2e 30 2e 30 2e 30 20 61   .0.0.0 a
0038: 74 20 6f 66 66 73 65 74   t offset
0040: 20 30 30 30 30 30 30 30    0000000
0048: 30                        0

Open in new window

0
TheLastStraw
Asked:
TheLastStraw
  • 5
  • 5
  • 4
5 Solutions
 
David L. HansenProgrammer AnalystCommented:
Sounds like a timeout issue.  Try adding "Application.DoEvents" in an area of the code that runs often, or better yet, have backgroundworker running whose sole purpose is to execute Application.DoEvents line.  This should happen every 20 or 30 seconds...to cause the pause in the backgroundworker just use "Threading.Thread.Sleep(20000)" between each doEvent firing.  Note: 20000 is for 20 seconds.
0
 
Dudge669Commented:
What, exactly, does your program do?  Does it do any kind of network communication?  Maybe a server that it talks to has some latency issues?  It's kind of hard to troubleshoot an issue like this without seeing the program or at least it's code.
0
 
David L. HansenProgrammer AnalystCommented:
Well this is best tested in debug mode.  Just open the app, perform any routine actions, so that you get to a point where a user might have been when it died, then wait.  Just let it sit for a good long time and you'll probably get an error.
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
Dudge669Commented:
You may also want to start extensive logging.  Make a log file that logs EVERYTHING the program is doing, including time of day for each entry.  Examine your log files after the program hangs to start narrowing down what your program is doing when the hang occurs.
0
 
David L. HansenProgrammer AnalystCommented:
Monitor system resources also, it could be allocating so much memory that in halts the processing completely.
0
 
TheLastStrawAuthor Commented:
Thanks for response guys. The application is a typical business database application in this case where account managers are handling planning on advertising campaigns. Typically a user will leave the application open all day without logging off and go back to it continuously throughout the day as the get feedback from advetrtising agencies and media owners.

The problem with the hanging is they typically leave the application when they hae completed some task and come back to it when they want to do something new. The database connections are made only when data is being retrieved so its not a case of timeouts as there is nothing running to timeout.

I cannot log anything as the application is not doing anything and no procedures are therefore in progress. It would be like leaving Excel open on a spreadsheet and then later going back to fill i a new cell.  The only thing that could happen in the meantime may be the garbage collection or something like that.

Note, I never or rarely experience this issue on my development PC and it appears to happen to some users  much more frequently than others.  THe application is quite large and does use a fair bit of memory but if  I monitor the PC while the application is hung the CPU is not near 100% not is the memory usage at capacity or near capacity. It just appears that the operating system apears to have a problem switching the application back into active memory.

When I am saying ts using alot of memory it would still be under 100megs and all PC's have about a gig of memory.

The application is talking to a backend Windows 2003 server for Database access but again reactivating the application does not start any database access activity and the user is not getting the opportuninty to start anything that does.  

It strikes me more s a system context switching issue , between my app and other apps on PC. but not sure how to go about diagnosing this or how to prevent this happening.
0
 
Dudge669Commented:
That is quite strange.  If it does seem to be happening more for some users and NEVER for other users at all, I would start watching the running processes, installed programs, user-hive registry size, etc on the machines and see where they are different.

You mention that the program isnn't doing anything while they're away?  All database connections and cursors are closed, no network sockets listening, nothing?  It's just sitting there waiting for someone to click a command button or something?  Just making sure.  You may want to have the program start doing something during it's idle time.  Have the program log something in the application event log or to a text file once a minute or something if it's been 5 minutes since a button was pressed or sql query executed.  Make it do something.  Don't let it fall asleep, you know?  This will also give you a better idea of just when, exactly the program is hanging.  Is it always exactly 15 minutes after the user leaves their desk?  Always at 3:45 when the janitor plugs in the vacuum?  Some kind of logging may help point out details that seem silly at first.  I've seen it many times.
0
 
TheLastStrawAuthor Commented:
I have written system using CSLA framework with Business Objects running locally at present. Ie connections made from Client PC directly to SQL when an object is is doing a DB access.  Opens connection in business layer, populates a reader and closes  and disposes connection to DB. reader passed back to front end.

I can use other methods of accessing Db like deploying middle tier on server but thats not relally issue.

I will test logging an event on the client and believe that may work based on feedback I got from users, i.e app only freezes when they leave it for a while.

I did read up on some slmilar issue somewhere where problem disappearred by upgrading NIC to latest release. Would this be a runner?  Would this only be case if network activity was required on my app at timeof reactivation.
0
 
Dudge669Commented:
It could definitely have something to do with your NIC.  It also may be related to the phase of the moon - it's really hard to tell until you start narrowing down the similarities between the users that this is happening more frequently to.  You mentioned it happens for some users more frequently than others, right? Are there any users that it NEVER happens to?  I would start comparing their workstations...
0
 
TheLastStrawAuthor Commented:
Dudge669,

I agree wholeheartedly with you. Unfortunately not always possible when you provide an application to a customer. Customer is inclined to exaggerate the issues and rather than admit to having experienced them before never admit this hoping you will solve it for them or state everyone is experiencing them where may be down to a few users.  I have requested info similar to that mentioned by you to attempt to identify a pattern but do not expect feedback until next week.  

I am on-site tomorrow and hope to try investigate further. Thanks for all feedback which is appreciated. I have also cleared some references from CSLA project added by author , I suspect for VS2008 using .NEt 3.X while I am using .net 2, which were showing up a missing.  This has had affect of removing  all  warnings from my builds (previous count of 16 warnings). Also intend re-publishing tomorrow.

Issue occurs during both spring and neap tides too?

0
 
Dudge669Commented:
Maybe you could build some kind of event log scanning subroutine into your app with a 'report back to you' email.  You can look for those event log notices signifying that the app is hanging youself, instead of relying on the users to tell you.  Or make a "successful shutdown" marker file or registry key somewhere.  Set a key at program start up and clear it at program successful shutdown.  If your program starts and the marker key/file is already there, you know the app didn't shut down correctly last time and you can have it notify you somehow.  Or record that fact to a small log file in their mydocs folder that you can ask them to read to you over the phone...
0
 
David L. HansenProgrammer AnalystCommented:
Please try my solution with the doEvents in a Backgroudworker as mentioned above.  It is so easy to implement and test (just a few lines of code).  Add a background worker and have it run: "Application.DoEvents" every minute or so.  Just test this option...I think you'll be pleasantly suprised...I've had it solve VERY similar issues.
0
 
TheLastStrawAuthor Commented:
SL8rz,
Will try on site tomorrow and update ypu early next week when I have had a chance toreview. Again thanks to all for responding!
0
 
TheLastStrawAuthor Commented:
Just a quick note.
1 Issue not completely resolved even though I have implemented all solutions metioned.

One of customer's PC causing most of issues appears to have operating system isues and Client was unfailrly escalating it to me.

I have added exception handler in main thread to trap unhanlded exceptions and email them to me. This has helped identify some software issues and pointed to occasional timeout issues on database pooled connections.

I added the doevents as suggested in one post but while this may have reduced the number of occurrences I can cannot confim this.

Finally, will continue to monitor this and create a new post if I get to actual cause of unexplained hangs.

Thanks again to guys who assisted in diagnosing issue.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 5
  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now