问题
We're currently changing the thread priority of a WCF RIA service call using this code.
System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Lowest;
Once, the operation is invoked, we change the priority to the lowest priority and the operation continues to run.
Will this have potential negative affects on other operations that are running. Also, how are these threads even handled on the server in terms of which operations get run on each thread. 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.
Any help is appreciated
回答1:
Also, how are these threads even handled on the server in terms of which operations get run on each thread.
A WCF call is generally dispatched to a thread managed by a thread pool. Once that thread has serviced the request it is returned to the pool.
Will this have potential negative affects on other operations that are running.
It may if the thread pool does not revert the priority back to normal. Remember, that thread will eventually get used to service other requests and work items.
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.
No, a new thread is not created for each request. Yes, you may end up effecting other operations that are dispatched to that thread at a later time.
来源:https://stackoverflow.com/questions/9983136/changing-thread-priority-on-wcf-ria-service