p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Windows 8 Application Development (http://p2p.wrox.com/forumdisplay.php?f=698)
-   -   Chapter 5: Asynchronous Development Platform (http://p2p.wrox.com/showthread.php?t=89809)

scarfinv April 8th, 2013 10:25 PM

Chapter 5: Asynchronous Development Platform
 
I'm working through this book, doing the exercises in VB instead of C#.

I'm in Chapter 5, and have reached the section called Implementing Cancellation in C# 5.0.

I'm finding it difficult, since it is talking about creating a CancellationTokenSource object, and then passing its token to the await wc.DownloadStringTaskAsync method. (wc is a WebClient object).

When trying to write the code (in VB), the DownloadStringTaskAsync method doesn't accept a second parameter at all.

I was able to get cancellation working by simply calling the wc.CancelAsync method from inside btn_Cancel_Click.

However, the next step on (page 149, step 8) is then to implement a timeout. It appears that now I really do need to use a CancellationTokenSource object, but I have no idea how to do this, given that I can't associate it with my DownloadStringTaskAsync (or at least not the way the book says to do it)?

Any help would be welcome! Even better if from a VB perspective, rather than C#!


All times are GMT -4. The time now is 10:06 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.