Solved

VB.Net Application Intermittently Hanging

Posted on 2008-10-29
14
1,400 Views
Last Modified: 2013-11-07
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
Comment
Question by:TheLastStraw
  • 5
  • 5
  • 4
14 Comments
 
LVL 15

Accepted Solution

by:
David L. Hansen earned 200 total points
ID: 22833247
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
 
LVL 2

Expert Comment

by:Dudge669
ID: 22833368
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
 
LVL 15

Expert Comment

by:David L. Hansen
ID: 22833447
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
 
LVL 2

Assisted Solution

by:Dudge669
Dudge669 earned 300 total points
ID: 22833468
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
 
LVL 15

Assisted Solution

by:David L. Hansen
David L. Hansen earned 200 total points
ID: 22833519
Monitor system resources also, it could be allocating so much memory that in halts the processing completely.
0
 
LVL 2

Author Comment

by:TheLastStraw
ID: 22837378
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
 
LVL 2

Expert Comment

by:Dudge669
ID: 22837642
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Author Comment

by:TheLastStraw
ID: 22839076
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
 
LVL 2

Assisted Solution

by:Dudge669
Dudge669 earned 300 total points
ID: 22840254
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
 
LVL 2

Author Comment

by:TheLastStraw
ID: 22840855
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
 
LVL 2

Assisted Solution

by:Dudge669
Dudge669 earned 300 total points
ID: 22841034
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
 
LVL 15

Expert Comment

by:David L. Hansen
ID: 22841148
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
 
LVL 2

Author Comment

by:TheLastStraw
ID: 22845763
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
 
LVL 2

Author Closing Comment

by:TheLastStraw
ID: 31516321
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now