Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Threading Error (calling dispose from a background thread)

More
17 Apr 2014 18:06 #1861 by cdunlap
Replied by cdunlap on topic Threading Error
There have been no real performance hits with the workaround, so I think this will be acceptable for now.

Thanks for your assistance.

Please Log in or Create an account to join the conversation.

More
16 Apr 2014 07:09 #1847 by support
Replied by support on topic Threading Error
I have written various tests and tried different combinations (processor architecture, Debug/Release builds, C#/VB.NET, run in test host vs. run directly in WinForms app), but I was unable to reproduce this issue so far.

The one thing I have *not* done yet is to make the original project run on my machine (it seemed too complicated, given that I need to attach the database, change the tag names etc.). Do you think it is now the moment to make this effort?

Note: I will be mostly unavailable till Tuesday.

Please Log in or Create an account to join the conversation.

More
14 Apr 2014 20:02 #1831 by cdunlap
Replied by cdunlap on topic Threading Error
Hi,

I am not attempting to dispose of the object manually. I guess this means it should stay alive until it is garbage collected.

Please Log in or Create an account to join the conversation.

More
13 Apr 2014 14:21 #1828 by support
Replied by support on topic Threading Error
[project file received - Project Enterprise.zip]

I have a question.

When you say

It appears that when the application tries to destroy an EasyDAClient object in a background thread


are you talking about a specific, explicit call to EasyDAClient.Dispose()? Because, I cannot find it in the app... . Can you point me to the file and method/line where it is done, or (even better) provide a call stack that leads to the Dispose()? Or, are we instead of some kind of system-induced call - when and how?

Thank you

Please Log in or Create an account to join the conversation.

More
11 Apr 2014 12:58 #1825 by cdunlap
Replied by cdunlap on topic Threading Error
Here's an update from our end:

I currently have a workaround for this problem. Analysis of the event log revealed that just prior to the crash of the application, an OutOfMemoryException would be thrown in the constructor of the SanritsuDownload class. I converted the class into a singleton class and used a ConcurrentQueue to feed download requests, which then would actually be performed in a long-running BackgroundWorker.

I can't see inside the EasyDAClient code, but I suspect that it has a problem releasing resources when the application is done with it. Either that, or I'm doing something incorrectly with respect to managing the object

Please Log in or Create an account to join the conversation.

More
04 Apr 2014 08:45 #1813 by support
Replied by support on topic Threading Error
Calling Dispose is recommended but not strictly necessary. What you are doing should be possible; it might be a bug in the component.

Can you send me the project, so that I can reproduce it easily?

Please Log in or Create an account to join the conversation.

More
03 Apr 2014 20:34 #1812 by cdunlap
Threading Error was created by cdunlap
I have a VB.NET application built on OPC Data.NET. We create instances of the EasyDAClient object in separate threads because we do not want to tie up the UI thread waiting for writes to complete. The threads are initiated through BackgroundWorker objects.

It appears that when the application tries to destroy an EasyDAClient object in a background thread, we get the exception shown here:

<Exception><ExceptionType>System.Threading.ThreadStateException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Thread has not been started.</Message><StackTrace> at System.Threading.Thread.JoinInternal(Int32 millisecondsTimeout)
at System.Threading.Thread.Join()
at OpcLabs.EasyOpcRaw.DataAccess.CDAInnerPump.stop(CDAInnerPump* )
at OpcLabs.EasyOpcRaw.DataAccess.CDAInnerPump.{dtor}(CDAInnerPump* )
at OpcLabs.EasyOpcRaw.DataAccess.CDAInnerPump.__vecDelDtor(CDAInnerPump* , UInt32 A_0)
at OpcLabs.EasyOpcRaw.DataAccess.FreeObject(CObject*&amp;amp; pObject)
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.!RawEasyDAClient()
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.Dispose(Boolean A_0)
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.Finalize()</StackTrace><ExceptionString>System.Threading.ThreadStateException: Thread has not been started.
at System.Threading.Thread.JoinInternal(Int32 millisecondsTimeout)
at System.Threading.Thread.Join()
at OpcLabs.EasyOpcRaw.DataAccess.CDAInnerPump.stop(CDAInnerPump* )
at OpcLabs.EasyOpcRaw.DataAccess.CDAInnerPump.{dtor}(CDAInnerPump* )
at OpcLabs.EasyOpcRaw.DataAccess.CDAInnerPump.__vecDelDtor(CDAInnerPump* , UInt32 A_0)
at OpcLabs.EasyOpcRaw.DataAccess.FreeObject(CObject*&amp;amp; pObject)
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.!RawEasyDAClient()
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.Dispose(Boolean A_0)
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.Finalize()</ExceptionString></Exception>

Is there something that I am doing to cause this issue? It looks like maybe the client is trying to access a thread that is in the "Unstarted" state?

How should I be handling the disposal of these objects (if at all)? From reading, it looks like I should call Dispose before exiting as opposed to waiting for the garbage collector?

Thanks for your help.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.056 seconds