简体   繁体   English

AsyncWaitHandle.WaitOne阻止CLR线程吗? 或者它是否创建了I / O完成端口?

[英]Does AsyncWaitHandle.WaitOne block the CLR thread? Or does it create an I/O completion port?

I have that question, does AsyncWaitHandle.WaitOne block the CLR thread? 我有这个问题, AsyncWaitHandle.WaitOne阻止了CLR线程吗? or does it create an I/O completion port? 或者它是否创建了I / O完成端口?

For example, when I run my application I launch a task 'A' that initializes some data, when new requests arrives, I want them to wait till 'A' has finished, so I can do a IAsyncResult.AsyncWaitHandle.WaitOne , but... does it block the calling thread till 'A' ends or does it create a I/O completion port that will be also notified when 'A' finish. 例如,当我运行我的应用程序时,我启动一个初始化某些数据的任务'A',当新请求到达时,我希望它们等到'A'结束,所以我可以做一个IAsyncResult.AsyncWaitHandle.WaitOne ,但是。 ..它是否阻止调用线程直到'A'结束或创建一个I / O完成端口,当'A'完成时也会通知它。

If not, is there a way to do that? 如果没有,有没有办法做到这一点?

Regards. 问候。

Yes, it blocks the thread, but like any other WaitHandle , it blocks in the OS kernel so it doesn't take any cpu time. 是的,它会阻塞线程,但是像任何其他WaitHandle ,它会在操作系统内核中阻塞,因此不需要任何CPU时间。

If you don't want to block your thread, but do want a "callback", you can use the thread pool: 如果您不想阻止线程,但确实需要“回调”,则可以使用线程池:

ThreadPool.RegisterWaitForSingleObject( waitHandle, callback, ...

暂无
暂无

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

相关问题 AsyncWaitHandle.WaitOne的详细信息 - Details of AsyncWaitHandle.WaitOne 在非UI线程上调用AsyncWaitHandle.WaitOne时出现NotSupportedException - NotSupportedException when calling AsyncWaitHandle.WaitOne on non-UI Thread 调用基于异步任务的WCF方法是否利用I / O完成端口或线程池线程来调用延续? - Does calling asynchronous Task based WCF method utilize the I/O completion port or a Thread Pool thread to call the continuation? 使用 AsyncWaitHandle.WaitOne 在 C# 中执行一行之前添加延迟 - using AsyncWaitHandle.WaitOne to add delay before executing a line in C# 如果侦听服务已关闭,为什么TcpClient.BeginConnect结果的AsyncWaitHandle.WaitOne不返回false? - Why doesn't TcpClient.BeginConnect result's AsyncWaitHandle.WaitOne return false if the listening service is down? 我什么时候调用BeginXXX()时CLR创建IO线程 - When does the CLR create the IO thread when I call BeginXXX() 如何将完成端口操作(I/O 绑定函数)排队到 CLR 线程池 - How to queue a completion port action (I/O bound function) to CLR ThreadPool 为什么 IAsyncResult.AsyncWaitHandle.WaitOne 在 wifi 没有 inte.net 连接且移动数据已打开时返回 false? (XAMARIN) - Why does IAsyncResult.AsyncWaitHandle.WaitOne return false when wifi has no internet connection and mobile data is turned on? (XAMARIN) CLR Max I / O(端口完成)线程确定 - CLR Max I/O (PortCompletion) Thread Determination ManualResetEvent - WaitOne()似乎在某些时候没有释放线程 - ManualResetEvent - WaitOne() does not seem to release thread at some point
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM