-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Winform not work perfeclty #202
Comments
Hi Frank, Take a look at #190 because I think you have the same problem I had... and sometimes still have... WPF and Windows Forms should be doing different things with view models. My problem was that the ViewModel was "frozen" and OPCUA lib did not even start. When I subscribe for some events in the view model, then "magically" the ViewModel starts to work and communicate. I think this is related to async code not executing or maybe the main task is paused. Sometimes, my ViewModels run without doing anything special to them. So for me this is still an open issue (not related to this library, I think, but definitely a show stopper if you face it). |
Hi, best regards |
Well, in my case the VM did not read and write. If your problem is only related to the VM cannot write, then maybe is a Thread problem. You can try marshalling to the current Thread to write the values to the VM (how... it depends on your code). If the problem is related to no reading and no writing, then you must try to create a Task/Thread for that ViewModel. I am not still 100% sure of how this works, but in my case I could accomplish that by subscribing to a PropertyChanged event of the VM from the View. As I am using ReactiveUI MVVM Framework, this translates in using a WhenAnyValue method with whatever VM property. Maybe this it not your case, how are you using the VM in WinForms? |
Could you share some code of the ViewModel that is not working? |
HI, Model
Helper
Usage
Best reagrds |
Thanks for the code. Everything looks okay. Tell us more about when the ViewModel does not write to the PLC. Are you using an editor that is bound to a property of the ViewModel? The library has trouble with setting properties when:
|
Hi,
In some case using editor. best regards |
From a non-UI thread, or from the PropertyChanged handler you need to do one of the following: Option 1
option 2
|
I create extension with reflection and write/read value and retrive nodeid from attribute. Best regards |
hI, Best regards
|
Very nice! Thanks. |
Hi,
excellent work. It happens in winform that the ViewModel sometimes does not write to the PLC
Best regards
The text was updated successfully, but these errors were encountered: