Question

On Async webservice on complete event, there is a code such as:

Debug.Assert(Dispatcher.CheckAccess()); // don't do marshaling here- it's already runinng on UI thread!

Does anybody know what happens if I remove this code? Or, able answer my questions?

Was it helpful?

Solution

That's a debugging assertion. Removing it will have no effect on production code.

What it's doing, though, is using Dispatcher.CheckAccess() to verify that you are on the UI thread during the exectution at that point. If you call that method from a background thread, the assertion will fail.

Removing this may have an impact on your ability to debug that in the future.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top