views:

167

answers:

1

On Async webservice on complete event, there is a code like belows.

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?

+6  A: 

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.

Reed Copsey
Excellent! thank you so much Reed.
ariso