C# 中的初学者线程 [英] Beginners threading in C#

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

问题描述

您能否推荐一系列优秀的文章或者最好是一本书,介绍如何开始使用线程,尤其是 C#?我主要是在控制台应用程序和 ASP.Net 应用程序中寻找线程的使用.

Can you recommend a good series of articles or preferably a book on how to get started with threading in general and in C# in particular? I am primarily looking for the use of threads in console applications and in ASP.Net apps.

我只了解线程的基本知识,并且知道这里有龙",因此在开始使用它们之前希望对它有一个良好的了解.

I understand only the very basics of threads and know that "here be dragons", so want to get a good grounding in it before I start using them.

我很好奇的是诸如拥有线程池的概念、如何管理它的大小、如何选择将事物排队直到线程可用与强制启动新线程等.另外,我知道 IIS 有很多内置的线程处理,所以任何解释如何在 IIS 下使用 ASP.Net 中的线程以及它与控制台 C# 应用程序中的线程有何不同的内容都很有趣.

Things I am curious about are things like the concept of having a threadpool, how you manage the size of it, how you choose for things to be queued until a thread is available vs forcing a new thread to start etc. Also, I understand that IIS has lots of built-in thread handling, so anything that explains how to work with threads in ASP.Net under IIS and how it differs from threading in a console C# applicaion is interesting.

我的预期用途包括:

  • 用户在 ASP.Net 页面上做了一些事情,导致我的服务器端代码需要连接到另一个系统并执行冗长的操作,所以我想通过触发该操作快速将控制权返回给用户到另一个线程.用户可以通过 AJAX 继续观看进度或干脆离开 - 毕竟网络是无状态的 :)

  • The user does something on the ASP.Net page that causes my server-side code to need to connect to another system and carry out lengthy operations, so I want to return control to the user quickly by firing that action to another thread. The user can keep watching progress through AJAX or simply move away - the web is stateless after all :)

使用即发即弃模式(有很多示例代码,我想更多地了解它们的工作原理)

Use of Fire and Forget patterns (lots of sample code out there, I want to understand more about how they work)

谢谢

推荐答案

以及我自己由 Andrew 链接的文章,Joe Albahari 有 另一个教程.

As well as my own articles linked by Andrew, Joe Albahari has another tutorial.

如果您想要真正彻底的检查,请阅读 Joe Duffy 的 Concurrent在 Windows 中编程.

If you want a really thorough examination, read Joe Duffy's Concurrent Programming in Windows.

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

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