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.

DispatcherSynchronizationContext does not exist

More
15 May 2010 16:46 #19 by support
From: W.
Sent: Friday, May 14, 2010 3:32 PM
To: Zbynek Zahradnik
Subject: RE: Data.NET in VS 2010

Hello Zbynek,

.... This is in a new project in VB.NET 2010 targeting the 3.5 framework. I will try and get you the code I am using. .... In the meantime I have made the customer aware that the workaround mentioned will be fine.

Thanks,

W.




From: Zbynek Zahradnik [This email address is being protected from spambots. You need JavaScript enabled to view it.]
Sent: Thursday, May 13, 2010 8:56 AM
To: W.
Cc: R.
Subject: RE: Data.NET in VS 2010
W.,
I could not reproduce this problem – but with VS2010, I ran into other issue, which I am working on. Is this happening with a project converted from VS2008, or with a new project? Can you send me that project?

In general, the answer is that the SynchronizationContext property of EasyDAClient should be set whenever you care about the thread which make event notifications from EasyDAClient. If you do not care about the thread or the timing of event notifications, you can leave the SynchronizationContext as null. Otherwise, you should set it to a synchronization context proper for the environment. In many cases the Designer does it for you, as in the code at the bottom, which assures uses a WinForms synchronization context, and assures that event notifications are made on the main thread of the form – which is the UI thread that is the right one for updating UI controls during notifications and so on. If the synchronization context was not set, you can run into problems updating the UI controls from within the event notification; however if you just need to manipulate some internal data structures, it’s fine to have no synchronization context.

The line at the bottom is fine in VS 2010 WinForms too, so go ahead and use it.

The first piece of code appears to be from WPF application, which uses a different synchronization context class, but the general principle is the same.

Best regards,
Zbynek Zahradnik

From: W.
Sent: Wednesday, May 12, 2010 4:10 PM
To: Zbynek Zahradnik
Cc: R.
Subject: Data.NET in VS 2010

Hello Zbynek,

We have a customer who is attempting to use the OPC Data.NET in VS 2010. They are targeting the 3.5 framework but I get the same error when targeting the 2.0 FW. They get an error saying something like "Type System.Windows.Threading.DispatcherSynchronizationContext does not exist". So we went ahead and commented out the two lines below (line #1 is incomplete but you should get the idea). The application was able to read tags no problem. I was wondering what implications this has on the functionality of the application. Does it remove desired or necessary functionality? If so what?

'Dim DispatcherSynchronizationContext2 As System.Windows.Threading.DispatcherSynchronizationContext =
'Me.EasyDAClient1.SynchronizationContext = DispatcherSynchronizationContext2

I also noticed that in VS 2008 the following line is used instead.
Dim WindowsFormsSynchronizationContext1 As System.Windows.Forms.WindowsFormsSynchronizationContext = New System.Windows.Forms.WindowsFormsSynchronizationContext
Can I just have the user change to this code? Please let me know.
Thanks,
W.

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

Moderators: support
Time to create page: 0.055 seconds