简体   繁体   English

将ASP.NET Web应用程序连接到Windows Service应用程序

[英]connect ASP.NET web application to Windows Service application

I have one windows service application and one ASP.NET web application, both created by C#. 我有一个Windows服务应用程序和一个ASP.NET Web应用程序,均由C#创建。 Both applications get data from the database(SQL server). 两个应用程序都从数据库(SQL Server)获取数据。

Once I update database from web application, how could I inform service application to reload data from database? 从Web应用程序更新数据库后,如何通知服务应用程序从数据库重新加载数据?

Right now our solution is to use service controller to restart windows service application. 现在,我们的解决方案是使用服务控制器重新启动Windows Service应用程序。 Is there any low cost solution, like communication between service application and web application? 是否有任何低成本解决方案,例如服务应用程序和Web应用程序之间的通信?

By the way, my boss hate polling method... 顺便说一句,我的老板讨厌投票方法。

If wcf is a choice, can anyone post some materials? 如果可以选择wcf,谁能张贴一些材料?

Thanks a lot! 非常感谢!

you can implement workflow services that runs as a windows service. 您可以实施作为Windows服务运行的工作流服务。 That service must have an activy that can be called over net.tcp request and processes your request. 该服务必须具有可通过net.tcp请求调用的活动,并处理您的请求。 I'm using this solution and works fine. 我正在使用此解决方案,并且工作正常。 Other way is the service use the database to check if it's necessary to perform the reload. 另一种方法是服务使用数据库检查是否有必要执行重新加载。

You can take advantage of Service Broker 您可以利用Service Broker

In a nutshell: using the SqlDependency class you can wire up an event in C# that will fire whenever a table gets updated. 简而言之:使用SqlDependency类,您可以在C#中关联一个事件,该事件在表被更新时将触发。 At that point in time, you can re-load the new data. 届时,您可以重新加载新数据。

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

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