I am currently developing a WCF publishing publishing service. The subscriber is a winform application. Since the subscriber needs to implement a callback method for the service, which in my case is the PostReceived () method, and the publisher has the PublishPost () method.
For the PostReceived () method for my winform, it cannot access the winform UI thread. The subscription method is done according to my main method. How to program the PostReceived () method so that it can access labels and those for my main form?
EDIT
what I tried so far calls the mainForm object from my program.cs, but it crashes when I run all 3, indicating an error that it cannot access the user interface thread.
EDIT 2
I tried using the following code, but there is an error for it.
mainForm b; public void PostReceived(string postSampleData) { b.BeginInvoke((MethodInvoker)delegate() { b.lblSearch.Text = "lakjslkaja"; });
After running the code, an error appears
Object reference not set to an instance of an object.
Any idea how to fix this?
source share