Thursday, July 9, 2009

How do two c# .Net programs communicate to each other?

Hi,


Let suppose there are two programs(built in c# .Net).In first program ,where i put the textbox1 and a "send" button.In second program i put just textbox2.


I want ,when typing is complete in first program and after this I click on the send button then all data transfer from !st program to 2nd program.(2nd program is already open)


means all typing word of textbox1 ,show on to the textbox2.





thanks

How do two c# .Net programs communicate to each other?
The problem you have is that HTTP does not maintain state. Therefore, there is no way for the server to know whether two Web applications are connected to one another, because the server does not see the Web pages as threads, the way it does compiled programs; nor does it have a practical way to know that the other page is open.





You'd need to use an application that maintains state to accomplish what you want, such as by ActiveX or the like.





And before other people say you could do this with AJAX, you can only work with the document in the current browser window with AJAX; you can't work with sites open in a different window, which this person clearly states is the case.
Reply:Assuming you're talking about windows forms, and not web forms, you can do this with interprocess communications. If you're working within the same project, you can follow this example: http://www.informit.com/articles/article...





For more information on interprocess communications, check out microsoft's Interprocess Communications information on MSDN. http://msdn.microsoft.com/library/defaul... I believe they have an example piece of code that does almost exactly what you want.





If you want to go over the Local Area Network (LAN), you'll need to use TCP/IP (or other networking protocol). If that's the case, repost your question mentioning this, and I'll point you to where to find that (in MSDN).





If you're looking to do communications for web apps, try looking up Windows Communications Foundation.

wallflower

No comments:

Post a Comment