简体   繁体   English

.NET中应用程序之间的通信

[英]Communication between apps in .NET

I have an application suite I'm coding at work that consists of multiple programs each designed to handle a specific task. 我有一个正在编写的应用程序套件,其中包含多个程序,每个程序旨在处理特定任务。 For example, one app lets you search your list of customers and make a reservation for that customer to check out equipment. 例如,一个应用程序可让您搜索客户列表并预订该客户以检出设备。 Another app lets you look up that reservation that was already made, and proceed straight to check out where we record what equipment they took, etc. 另一个应用程序可让您查找已进行的预订,然后直接检查我们在哪里记录他们购买了什么设备,等等。

I'm also designing a notification system to go along with this suite. 我还在设计一个与此套件一起使用的通知系统。 (if you've used Groupwise email, picture it like the email notifications. Or even the reminders on Google calendar). (如果您使用过Groupwise电子邮件,则将其像电子邮件通知一样进行生动描述。甚至可以在Google日历上进行提醒)。 I'd like to have the user only need to log into one main application which is also the notification app. 我想让用户只需要登录一个主应用程序,它也是通知应用程序。 Then every other app they opened in the suite would check some system variable/.NET object or whatever, and see that they're already logged in and not require them to do so again. 然后,他们在套件中打开的所有其他应用程序都将检查某些系统变量/.NET对象或其他内容,并查看它们是否已经登录并且不需要再次登录。 Btw, this "login" is actually to log into MySQL, which is our database of reservations, checkouts, inventory state, dept customers, etc. 顺便说一句,这种“登录”实际上是登录到MySQL,这是我们的预订,结帐,库存状态,部门客户等数据库。

My question is: What's the best way to do something like this? 我的问题是:做这样的最好的方法是什么? Would it be by having each app search the .NET runtime for the main app and check to see that its currently logged in or something? 是让每个应用程序在.NET运行时中搜索主应用程序,然后检查其当前是否已登录? I've never done anything like this before. 我以前从未做过这样的事情。 Any suggestions appreciated. 任何建议表示赞赏。

Usually you use multiple processes in order to have separation of state, so that failure in one doesn't take down the whole bunch. 通常,您使用多个进程来分离状态,以便一个进程中的故障不会减少整个进程。 You seem to want the opposite, however. 但是,您似乎想要相反的选择。

So, use one main application process. 因此,使用一个主要的应用程序。 Whenever another applet is clicked (be it from Start Menu, desktop shortcut, etc), it forwards its command-line to the main application and closes. 每当单击另一个小程序(从“开始”菜单,桌面快捷方式等开始)时,它将其命令行转发到主应用程序并关闭。 The singular process receives the new launch request and opens the corresponding window. 单个进程接收到新的启动请求并打开相应的窗口。

Win32 has mailslot objects for this sort of thing, but I'm sure you can find a more .NET-purist approach using WCF or similar. Win32具有用于此类事情的mailslot对象,但是我相信您可以找到使用WCF或类似方法的.NET纯粹方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM