同步与异步之间的区别 [英] Different between Synchronization and Asynchronization

查看:80
本文介绍了同步与异步之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有同步和异步概念的问题吗?

除了在其他地方使用委托? :doh:

解决方案

发送电子邮件时,通常不希望立即得到答复,而是继续做其他事情-就像异步手术.希望在一两天内收到答复,如果重要的话,您将定期检查您的邮箱,也可能会发送剩余的邮件.

当您单击网页上的链接时-等待答复-就像同步操作一样.

由于我们实际上是在谈论编程,.Net有很多机制可以帮助您-因此某些阅读可能会有所帮助:

这是一本不错的免费电子书 [ ^ ].

System.Threading命名空间 [ IAsyncResult [异步过程:它允许工作分区,线程调度,取消支持,状态管理.它可以最大程度地提高代码的性能,同时专注于程序设计要完成的工作. (参考:msdn).例如:CPU中的多个内核.使用不同的内核同时完成不同的操作过程. 同步:作品按顺序执行.完成一个线程,然后其他线程可以启动. CPU的一个核心.一次可以执行一个动作过程. 在更多细节中. [同步​​] LINQ. IEnumerable或IEnumerable < T > 数据源,并且已推迟执行,这意味着直到枚举查询后,它们才开始执行. [ASynchronous]的主要区别是PLINQ尝试充分利用系统上的所有处理器.它通过将数据源划分为多个段,然后在多个处理器上并行地在单独的工作线程上对每个段执行查询来实现此目的.

大多数语句都来自mdsn


i problem with concept of Synchronization and Asynchronization?

Except delegate is used elsewhere? :doh:

When you send an email you usually don''t expect an immediate answer, but continue to do something else - that''s like an asynchronous operation. In a day or two, you will hopefully recieve a reply, if it''s important you will check your mailbox regularly, possibly sending a remainder too.

When you click on a link on a web page - you wait for the repsonse - that''s like a synchronous operation.

Since we actually are talking about programming .Net has a lot of mechanisms to help you out - so some reading might help:

Here is a nice free e-book[^] on threading and synchronization.

Checking out the classes in the System.Threading Namespace[^] is useful too, you should also know about the IAsyncResult[^] interface.

Regards
Espen Harlinn


Asynchronous process: It allows the partitioning of the work, the scheduling of threads, cancellation support, state management. It maximizes the performance of your code while focusing on the work that your program is designed to accomplish.  (Ref: msdn). For example: multiple cores in CPU. Different action process done at the same time with differnt cores.
Synchronous: Works perform in sequence. A thread that finish and then other thread can start. one core in CPU. can do one action process at one time.

In more details. [Synchronous] LINQ. IEnumerable or IEnumerable<T> data source, and have deferred execution, which means they do not begin executing until the query is enumerated.  [ASynchronous]The primary difference is that PLINQ attempts to make full use of all the processors on the system. It does this by partitioning the data source into segments, and then executing the query on each segment on separate worker threads in parallel on multiple processors.

most sentence are taken from mdsn


这篇关于同步与异步之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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