Why does ManualResetEvent fail to work in this synchronous call using Silverlight 4?

非 Y 不嫁゛ 提交于 2019-12-01 05:54:47

The networking callbacks in Silverlight will always arrive in the same thread as they were originated. For example, if you make a WebClient.DownloadStringAsync on the UI thread (i.e., on a button click event), then the callback call will be queued to be delivered on the same UI thread. However, your call to mre.WaitOne() is blocking the UI thread, so the callback is never invoked, and the mre.Set() call never happens.

So yes, that's a kind of enforcement in the asynchronicity of networking calls - you really can't do synchronous calls, even if they seem to be synchronous.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!