The reason this hangs is that the EndExecute
method marshals to the UI thread, but you're blocking the UI thread with your Sleep
call. It doesn't matter what technique you use to block the thread, anything you do is going to be causing a deadlock given that the method is called in a UI thread.
When developing in a SIlverlight environment you need to be able to program asynchronously, rather than using synchronous methods. If you are using C# 5.0 you can use the async/await functionality, which lets you write asynchronous code that appears synchronous, but it will be compiled into asynchronous calls that utilize callbacks/continuations, which is what you would need to do if you have not yet upgraded to that version.