1

In my App, I have a menu which loads a page making a http request to retrieve data. This http request usually last ~500ms or more.

Right now, I use an async method which nicely shows a progressRing during the loading.

Problem starts when I start to click on several menu input in a row (like 5 items in 1 second) => Pages loads one after the other.

I would like to kill the current process and launch the new process everytime the user select a new menu input.

I've found here and here that Thread.Abort is not a good practice. (was my first idea) I've also found here I might use a task. But I can't set up correctly the cancelation event (it's not like in the exemple, where they just loop and decide to raise the cancelation event, i have a http request going on)

Is there any good practice out there?

Thx a lot !

Community
  • 1
  • 1
T.Dupuis
  • 95
  • 1
  • 6
  • 1
    pass cancellation token into http request and when you want cancel the request just Cancel() method of cancellationtokensource. – loop Aug 09 '14 at 18:44
  • 1
    http://msdn.microsoft.com/en-us/library/jj155759.aspx – cfischer Aug 15 '14 at 12:19
  • Thx loop and Christian Fischer! Problem is: in my case i'm using a DLL I can't modify, which handle the http request process. And none of the implemented method allow me to use a cancellationtokensource. I realize I didn't mention it before, my bad. – T.Dupuis Aug 25 '14 at 14:15

0 Answers0