O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Synchronization Behavior

Asynchrony is a traditional source of interesting synchronization behavior due to the callbacks getting invoked upon completion of the operation (for example, on the thread pool). Without any manual synchronization to the context of the original caller of the asynchronous operation, all sorts of things can go bad. The most common example is attempting to update the UI from a callback, as shown in Figure 31.14.

Image

FIGURE 31.14 Cross-thread violations when updating the UI.

Just like the APM and the EAP, the TAP doesn’t require callbacks to happen in a particular context. When the task gets signaled—in ways discussed in the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required