c# - 更改 WCF RIA 服务上的线程优先级

标签 c# .net multithreading ria

我们当前正在使用此代码更改 WCF RIA 服务调用的线程优先级。

System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Lowest;

一旦调用该操作,我们将优先级更改为最低优先级,然后该操作继续运行。

这会对正在运行的其他操作产生潜在的负面影响吗?此外,这些线程在服务器上是如何处理的,即每个线程上运行哪些操作。我是否可能更改在同一线程上调用的其他操作的线程优先级,或者我可以确保在调用每个 RIA 服务操作时,都会为该操作创建一个新线程。

感谢任何帮助

最佳答案

Also, how are these threads even handled on the server in terms of which operations get run on each thread.

WCF 调用通常被分派(dispatch)到由线程池管理的线程。一旦该线程处理完请求,它就会返回到池中。

Will this have potential negative affects on other operations that are running.

如果线程池没有将优先级恢复到正常状态,则可能会出现这种情况。请记住,该线程最终将用于服务其他请求和工作项。

Am I potentially changing the thread priority of other operations that are invoked on the same thread or can I be assured that with every RIA service operation that is invoked, a new thread is created for that operation.

不,不会为每个请求创建一个新线程。是的,您最终可能会影响稍后分派(dispatch)到该线程的其他操作。

关于c# - 更改 WCF RIA 服务上的线程优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9983136/

相关文章:

c# - 在 Cosmos DB 中存储具有动态属性的对象

c# - 如何检查对象是否已在 C# 中释放

c# - 在 C# 中从 oracle 调用函数时出错

c# - XmlSerializer - 反射(reflect)类型时出错

c# - 字典在后台加载

c# - Task.Factory.StartNew() 生成对象未初始化错误

c# - 查找哪个 .NET 程序集定义了类型

c# - 通过 Teamviewer 连接时 WPF 应用程序崩溃

mysql - System.IO.FileNotFoundException : Could not load file or assembly 'MySql. 数据,版本=6.8.3.0

multithreading - Delphi 当应用程序在线程等待事件时终止时会发生什么?