Relationship between ManagedThreadID and Operating System ThreadID

前端 未结 4 1411
挽巷
挽巷 2020-12-09 21:56

I\'m working on a multi-threaded C# Windows application that makes frequent calls into a native dll. These are blocking calls which can sometimes last quite a long time.

4条回答
  •  一整个雨季
    2020-12-09 22:47

    How about using Abortable ThreadPool?

    From the article;

    Instead, consider a thread pool implementation that handed you back a cookie of sorts for a queued work item. The pool could then also provide a Cancel method that would take one of these cookies and cancel the associated work item, removing it from the queue or aborting the executing work item as appropriate. Implementing a custom thread pool for this task probably isn't the best idea, but there are other alternatives

提交回复
热议问题