简体   繁体   English

C#Express 2010多线程

[英]C# Express 2010 Multi-Threading

I have a windows app that I have been running in c# Express 2008 for a year and have been trying to convert it over the last few days to 2010. The problem I am having is it is a multi-threaded application that has to run a series of code every second. 我有一个Windows应用程序,我已经在c#Express 2008中运行了一年,并且一直在尝试将其转换为2010年的最后几天。我遇到的问题是,它是一个多线程应用程序,必须运行每秒的一系列代码。 What it does is have a main thread, that calls 3 worker threads, waits for them to finish then does some additional processing, sleeps till 1 second and runs again. 它所做的是有一个主线程,该线程调用3个工作线程,等待它们完成,然后执行一些其他处理,休眠直到1秒,然后再次运行。

The problem is part of the code can call a web service that takes 8 seconds to respond, so this bit of code gets called using ThreadPool.QueueUserWorkItem. 问题是代码的一部分可以调用需要8秒钟才能响应的Web服务,因此可以使用ThreadPool.QueueUserWorkItem调用这段代码。 The problem is when running in 2010 when this part of the code gets called the main thread continues to run but when it awakens the sub threads it hangs until the Threadpool method finishes running. 问题是在2010年运行时,这部分代码被调用为主线程继续运行,但是当唤醒子线程时,它将挂起,直到Threadpool方法完成运行。

This never happens in 2008. Any suggestions? 这在2008年从未发生过。有什么建议吗? So far I put that bit of code in it's own thread rather than using Threadpool but same issue. 到目前为止,我将那段代码放在了自己的线程中,而不是使用Threadpool,而是同样的问题。

I ported quite a lot of apps from VS 08 to 10 when I updated my IDE, Most of the time I've had no problems as long as all the values in the 'Properties' tab (do you call it a tab) look OK. 在更新IDE时,我从VS 08移植了很多应用程序,从VS 08移植到了10。大多数时候,只要“属性”选项卡(称为“选项卡”)中的所有值看起来都不错,我就没有问题。 Sometimes Visual Studio will automatically fix anything that's wrong, but other times, you've gotta go in and edit manually. 有时Visual Studio会自动修复所有错误,但是有时,您必须手动进行编辑。

Do you get any warnings in your error window? 您在错误窗口中收到任何警告吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM