WFC多线程安全 [英] WFC Multithreaded safety

查看:150
本文介绍了WFC多线程安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我目前正在使用WCF从事电影实践项目,而且我已经达到了一个里程碑,在这种情况下,多线程似乎是从额外内核中真正受益的好选择,可以说是一百的人立即订购了一部电影.我当前的结构看起来像这样:Server<->业务逻辑<-> DatabaseControler<->数据库

如果所有请求的席位都可用,业务逻辑"可以在那里检查付款,但是我也相信应该由它来处理何时应执行什么请求,并且由于将100个预订写入数据库中可能会导致混乱和失败.坐了多次,这将是一个很大的问题.

那么,谁能为我指出如何有效处理并发的正确方向呢?

谢谢-Jackie

Hey I''m currently working on a cinema practice project using WCF, and I''ve reach a milestone where multi-threading seems to be a great option to actually have benefits from the extra core in case, lets say hundred of people was to order a reservation to a movie at once. my current structure looks something like this: Server <--> Business logic <--> DatabaseControler <--> Database

The "Business Logic" is there to check payment, if all requested seats are availble etc. but I also believe it should be the one to handle when what request should be executed, and since writing 100 reservations into a database may end in chaos and seats taken multiple times this would be a huge problem.

So can anyone point me in the right direction of how to handle the Concurrency this will give in a efficient way?

Thanks - Jackie

推荐答案

在这种情况下,让数据库引擎担心并发性.业务逻辑中的会话是不相关的,不需要彼此了解.它只会减慢您的速度.只需确保您对即将要付款的客户有一些临时预订(这不是他们购物车中的商品).当他们付款时,它将保留他们的席位.几分钟后,如果付款未成功完成,则应再次将其释放以进行销售.但是实际的并发控制是由数据库事务完成的.

祝你好运!
In a scenario like this, let the database engine worry about concurrency. The sessions in the business logic are unrelated and don''t need to know about each other. It would only slow you down. Simply make sure you have some temporary reservation for customers that are just about to pay (which isn''t what''s put into their shopping cart). It will keep their seats available when they are in the process of paying. After a few minutes they should be released for sale again if the payment was not successful completed. But the actual concurrency control is done by database transactions.

Good luck!


流行语是ACID!

这里有一些要签出的链接.第一个只是一个不错的短篇小说示例:
http://michaeljswart.com/2011/07/acid -properties-by-example-and-counterexample-part-one-atomic/ [ http://msdn.microsoft.com/en-us/library/aa480356.aspx [ ^ ]

祝你好运!
The buzzword is ACID!

Here some links to check out. This first is just a nice short story example:
http://michaeljswart.com/2011/07/acid-properties-by-example-and-counterexample-part-one-atomic/[^]

Check out this link for more in depth information. Also check out the left tree with lots more information about transactions and all. The link is just a start start place but you can really eat your heart out.
http://msdn.microsoft.com/en-us/library/aa480356.aspx[^]

Good luck!


这篇关于WFC多线程安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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