winforms - C# - Communicate between two projects without two-way references -


i have 2 projects: project , and external project b (added via "add existing project in visual studio). project has reference project b, project b not have reference project a. have winform textbox in project project b able write text to. because project b doesn't have reference project a, can't call method created in project adds text textbox.

my question: possible have project b call method or write textbox without adding project reference?

circular references, while allowed in c#, symptom of poor architecture decisions. possible?

void myeventfunction(object sender, eventargs e) {     string txt = myclassfromb.getstringfromb();     textbox1.text = txt; } 

ideally, you'd want b's code give string want when need it, can control when gets updated.

alternatively, can delegates involved.

in b:

public class myclass {     public delegate void updatestringvar(string x);     private updatestringvar usv;     myclass(updatestringvar v)     {         usv = v;     }       void continuouslyrunningoperation()     {         string status = //get string         usv(status);     } } 

in a:

void updatetextbox(string x) {      textbox1.text = x; }  myclass myclass = new myclass(updatetextbox); 

something work if entire application single threaded, winforms controls have annoying "can access object thread created it" requirement, work required if b code running on different thread.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -