O'Reilly logo

Windows Presentation Foundation 4.5 Cookbook by Pavel Yosifovich

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

Using C# 5.0 to perform asynchronous operations

Using synchronous operations is really easy. Just call some operation, wait for it to return, and use the result. As we've seen, the problem is that slow operations block the calling (UI) thread or that thread does some hard CPU bound work; in both cases, the UI may become unresponsive. We have seen several ways to deal with that. These require running the long operation on a different thread, and when the results are finally available, marshal some code to update the UI.

The net result is code complexity, which grows quickly with more and more asynchronous operations happening. And if we consider more than one operation at a time, potential cancellations, adding timeouts, handling exceptions conveniently ...

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