开发者

Silverlight Sculpture generated application locking up on service calls (on some machines)

We have an application generated using the Sculpture software package. That means the project is roughly equivalent to the code in a Prism application.

Part of their model is that all WCF Service calls are performed synchronously, but on background threads (actually they are async calls as well, but the Sculpture background thread methods wait around for the response before executing any following code).

When we deployed the application, we found that around 50% of all machines tested would not get past the first service call. We cannot see any pattern in the machines that fail as they are have a mixture of both Debug and Release Silverlight runtime and Windows 7 on machines that work as well as fail. It fails the same 开发者_StackOverflow社区on different browser so is machine specific. The only clue is they all seem to be older PCs.

Ideas anyone?


Found the cause. There is a schoolboy error in their generated service calls.

What's wrong with this picture?:

while (true == userState.IsBusy)
{}

Ignoring the old-school use of true == (not needed in C#), basically their while loop locks up so tight on some machines the IsBusy state is never set. It also means that the application is always running 100% processor use whenever a service call was made.

We have fixed the problem by adding Thread.Sleep(100) in all the service call while loops. e.g.:

while (userState.IsBusy)
{ 
    Thread.Sleep(100);
}

Our app is now working on all Silverlight capable machines (as it should) and is using a lot less processor to boot.

To be fair we are not using the very latest release of sculpture, but it was quite suprising to see such a silly mistake in a commercial package.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜