What is the purpose of CheckAccess Manager?

In Async webservice, upon completion of the event, such code appears as:

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

Does anyone know what will happen if I delete this code? Or can you answer my questions?

+3
source share
1 answer

This is a debug statement. Removing it will not affect the production code.

However, it uses Dispatcher.CheckAccess () to make sure that you are in the user interface thread during exectution at this point. If you call this method from the background thread, the statement will fail.

Removing it may affect your ability to debug it in the future.

+7

Source: https://habr.com/ru/post/1720909/


All Articles