[英]How should I code my event handler for my C# Windows Form Application?
I am currently developing a C# Windows Form Application that I intend to let it interact with a server. 我目前正在开发一个C#Windows窗体应用程序,我打算让它与服务器进行交互。 The server will receive posting from a mobile application that I have developed and whenever a posting is received, my Windows Form Application should be notified and give me a notification.
服务器将从我开发的移动应用程序接收发布,并且每当收到发布时,我的Windows窗体应用程序应该得到通知并给我通知。
Eg My mobile application sends an message over to my server. 例如,我的移动应用程序将消息发送到我的服务器。 Once my server receives the message, my windows form application should display a new notification showing the content of the message received.
一旦我的服务器收到消息,我的Windows窗体应用程序应显示一个新通知,显示收到的消息内容。
The above scenario is just a example of what I intend to do with the whole thing. 上面的场景只是我打算用整件事做的一个例子。 Any idea how should I code my C# application in order to receive the information as stated above?
我知道如何编写我的C#应用程序以接收上述信息?
You can implement a WCF Service inside your server. 您可以在服务器中实现WCF服务。 You Windows Form application can be your WCF Service client.
您的Windows窗体应用程序可以是您的WCF服务客户端。
What you probably want is a Duplex Service 你可能想要的是双工服务
They way this would work is 他们这样做的方式是
As an alternative to the answer @parapura rajkumar, you could also investigate a Message Queue architecture , where the messages posted back from the mobile app are visible to both the server and the Windows client. 作为@parapura rajkumar答案的替代方案,您还可以研究Message Queue体系结构 ,其中从移动应用程序发回的消息对服务器和Windows客户端都是可见的。
Perhaps a little more heavy-weight but certainly worth consideration, especially if you suspect the application may need to grow in complexity in the future... 也许更重一点,但肯定值得考虑,特别是如果你怀疑应用程序可能需要在未来增加复杂性...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.