|
-
Apr 22nd, 2013, 12:48 AM
#1
Thread Starter
Registered User
Application gets hanged with multiple instances of a thread in VB.NET 2005
Hello.
We are developing an application which requires multi-threading. The thread has to run as long as the application is running. The application runs properly as long as there is only one instance of the thread. In case we start 2 instances of the same thread the application gets hanged after 15-20 minutes. We have used SyncLock for shared resources and delegates for updating GUI from thread. Still the application gets hanged.
We get the following exceptions when the application gets hanged:
1) An unhandled exception of type 'System.ExecutionEngineException' occurred in mscorlib.dll
2) .NET Runtime version 2.0.50727.3643 - Fatal Execution Engine Error (7A0BCA72) (80131506). ==> This gets recorded in the "My Computer-Manage-Event Viewer-Application"
In case the application is hanged, sometimes the "Memory Usage" for the ongoing processes seen in the Task Manager goes on increasing for our application.
Please guide us to solve the issue ASAP.
Thanks in advance.
-
Apr 22nd, 2013, 02:02 AM
#2
Re: Application gets hanged with multiple instances of a thread in VB.NET 2005
Using SyncLock is not necessarily a solution in itself. It's quite possible to create a deadlock, which is almost certainly what you're experiencing, with SyncLock blocks, even in a single-threaded app. If you have a single thread that enters a SyncLock block and then encounters another SyncLock statement that locks on the same object, you create a deadlock. There are other ways to create a deadlock too.
Bugs like this are often hard to diagnose but your best bet is probably to add some tracing. Write to a log file just before and just after entering a SyncLock block and just after exiting one. Write out the tie, the current location, the thread ID and the action (entering, entered, exited). You should then be able to determine if a thread is getting stuck at a gate and why. If it's not a SyncLock specifically that's the issue then you can do more tracing around other shared resources.
-
Apr 22nd, 2013, 08:46 AM
#3
Thread Starter
Registered User
Re: Application gets hanged with multiple instances of a thread in VB.NET 2005
Thanks for the reply jmcilhinney.
We have taken care to not create deadloack with nested SyncLocks.
In our application, there is 1 thread ("Thread_ABC") which can have more than 1 instance and 1 thread ("Thread_XYZ") which will have only 1 instance. When we run a single instance say "MyThread_1" with AddressOf("Thread_ABC") with the thread "Thread_XYZ", the app runs perfectly without hanging, indicating that there are no Nested SyncLocks.
But in case we create a second instance of the thread say "MyThread_2" with AddressOf("Thread_ABC") the application gets hanged after some time. The time for which the application will run without hanging is not fixed.
There are variables being shared across threads, which are enclosed in SyncLock.
We also have Graphical User Interface control Updates from the threads. These are handled by using Delegates.
We also tried one more option. We made 3 threads, "ThreadXYZ", "Thread_ABC_1" and "Thread_ABC_2", where "Thread_ABC_1" and "Thread_ABC_2" are same as "Thread_ABC" as in above case, i.e. the code under them is same. Now at run time active threads are "Thread_ABC_1", "Thread_ABC_2" & "Thread_XYZ". In this case also the app gets hanged after few minutes.
Please suggest as for the Root Cause of the application getting hanged and method to diagonize the issue.
Thanks.
-
Apr 22nd, 2013, 08:58 AM
#4
Re: Application gets hanged with multiple instances of a thread in VB.NET 2005
Is there more exception information?
-
Apr 22nd, 2013, 09:57 AM
#5
Thread Starter
Registered User
Re: Application gets hanged with multiple instances of a thread in VB.NET 2005
We do not get any exception message for user to click. But the exception ".NET Runtime version 2.0.50727.3643 - Fatal Execution Engine Error (7A0BCA72) (80131506). " as mentioned in 1st post are logged by the Windows OS under "My Computer->Manage->Event Viewer->Application". Sometimes we get exception "An unhandled exception of type 'System.ExecutionEngineException' occurred in mscorlib.dll" or " An unhandled exception of type 'System.ApplicationException' occurred in mscorlib.dll". We tried repairing the .NET Framework, but the issue persists. The occurence of exceptions of mscorlib.dll has reduced. Only the .NET Runtime Fatal Exception occurs frequently.
-
Apr 22nd, 2013, 10:07 AM
#6
Thread Starter
Registered User
Re: Application gets hanged with multiple instances of a thread in VB.NET 2005
No, we do not get any exception as message box for user. The exceptions are logged under "System Tools->Event Viewer->Windows Logs>Application" as ".NET Runtime version 2.0.502727.5466 - Fatal Exception Engine Error (6F2CEF72)(80131506)"
We sometimes get exceptions "System.ApplicationException" or "System.ExecutionEngineException" for mscorlib.dll
One more thing to ask:
In case there is a while loop with a condition in a thread. The condition never gets satisfied and the loop becomes an infinite loop, then can any of the above exceptions occur, get logged under "System Ttools-->Event Viewer" and complete application gets hanged?
-
Apr 22nd, 2013, 02:54 PM
#7
Re: Application gets hanged with multiple instances of a thread in VB.NET 2005
Could you do a mock up of what your threading code looks like or if you're allowed, post the threading code itself.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|