Shutting down a multithreaded application

前端 未结 6 1748
谎友^
谎友^ 2020-12-05 09:06

I\'m trying to write a ThreadManager for my C# application. I create several threads:
One thread for my text writer.
One thread that monitors some statistics.
M

6条回答
  •  鱼传尺愫
    2020-12-05 09:42

    The only specific issue I know about is this one: http://www.bluebytesoftware.com/blog/2007/01/30/MonitorEnterThreadAbortsAndOrphanedLocks.aspx

    But I'd avoid having to resort to a design like this. You could force each of your threads to check some flag regularly that it's time to shut down, and when shutting down, set that flag and wait for all threads to finish (with Join()). It feels a bit more like controlled shutdown that way.

提交回复
热议问题