Results 1 to 7 of 7

Thread: Application gets hanged with multiple instances of a thread in VB.NET 2005

  1. #1

    Thread Starter
    Registered User
    Join Date
    Apr 2013
    Posts
    4

    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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Registered User
    Join Date
    Apr 2013
    Posts
    4

    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.

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Application gets hanged with multiple instances of a thread in VB.NET 2005

    Is there more exception information?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5

    Thread Starter
    Registered User
    Join Date
    Apr 2013
    Posts
    4

    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.

  6. #6

    Thread Starter
    Registered User
    Join Date
    Apr 2013
    Posts
    4

    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?

  7. #7
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width