Windows服务+ Windows窗体应用程序。一个数据库。对并发建议 [英] Windows Service + Windows Forms application. One database. Advice on concurrency

查看:96
本文介绍了Windows服务+ Windows窗体应用程序。一个数据库。对并发建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有信息,SQL Server数据库的文件 - 我说的是自定义属性。这些是每个文件的类别和描述。

I have SQL Server database with information for files - I'm talking about custom properties. These are categories and description for each file.

Windows窗体应用程序的用户。但我也会让一个Windows服务,将跟踪的文件进行任何更改。如果发生变更(重命名,移动,删除)服务有相应更新同一个数据库。而且我认为它应该做的马上,没有任何延迟。

The Windows Forms application is for the user. But I will also make a Windows Service that will track any changes with the files. If a change happens(renamed,moved,deleted) the service has to update that same database accordingly. And I think it should do it right away, without any delay.

现在这将是我第一次拍WS加上我第一次将不得不处理并发(理论上我知道线程等)

Now this is going to be my first time making WS plus the first time I will have to handle concurrency (theoretically I know about threads and so on).

所以:


  • 首先,它是确定的,如果一个进程正在更新另一方法可以使用同时数据库?你需要处理的第一个地方的情况? (也许,FX在我们的日常生活用户的生活,我们不能修改一个文件时,它正被另一个进程)

  • First of all, is it OK if one process is updating a database another process may be using at the same time? Do you need to handle that situation on the first place? (Probably, fx in our daily "user lives" we can't modify a file when it's being used by another process)

的理念是这两个以共享一个数据源好?

Is the idea these two to share one data source good ?

如果是的话,如何处理并发?我可以使用WCF两个之间的消息,但当时确实解决方案必须是与WCF?因为我要利用这个首次以及。:D

If it is, then how to handle the concurrency ? I can use WCF for the messages between the two, but then does the solution have something to do with WCF ? Because I'm going to use this for the first time as well :D.

任何帮助表示赞赏。预先感谢的时候了!

Any help is appreciated. Thanks in advance for the time !

推荐答案

由于MS SQL是事务性的就没有什么大不了的。你只需要注意数据至极可能会被读取并通过一个进程更新 - 那里可以neccessary使用事务范围(这是一个.NET类)。)

Since MS SQL is transactional there will be no big deal. You just have to watch out for data wich might be read and updated by one process - there it can be neccessary to use a Transaction scope (that's a .NET Class ;)).

从查看软件架构的角度,你应该求索使用三层而不是两层应用程序:

From the Software architectural Point of view you should conside using a three-tier and not a two-tier application:

两层 :结果
实质上与客户机直接通信

Two Tier:
Essentially your System with the persistance-layer (DB) communicating with the Clients directly

三层的持久化层(DB)的系统:
持久性的二层< - >逻辑层(例如,一个WCF的业务处理应用程序逻辑)< - >客户(服务和表单 - 触发应用程序逻辑和显示效果)

Three Tier: Persistance-Layer <--> Logic-Layer (e.g. a WCF-Service handling the app logic) <--> Clients (Service and Forms - triggering app logic and showing results)

这篇关于Windows服务+ Windows窗体应用程序。一个数据库。对并发建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆