[英]STA thread for windows Service
我可以在Windows服务的Main中使用[STAThread],这有什么问题吗?
You can but it may not work as intended and can cause problems. 您可以但可能无法按预期工作,并可能导致问题。
The best way to work around this seems to be by starting a new Thread and setting its ApartmentState to STA 解决此问题的最佳方法似乎是启动一个新线程并将其ApartmentState设置为STA。
Have a read of this post for more info: 阅读这篇文章以获取更多信息:
.NET Windows Service needs to use STAThread .NET Windows服务需要使用STAThread
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.