0

In a bootstrapper, I have two views. Using the IRegionManager, I navigate between the first and the second view.

The first view contains a search box. The user types a string, clicks search. The first view passes the string over to the second view. The second view uses this string to call a service to get a list of items.

Everything works fine so far, but I would like to make this async that (also adding a ProgressIndicator). That is I do not want the application to lock when the user click on the search button.

I want the application to behave like so:

  1. The user enters a search string, and clicks on search (I have implemented.)
  2. The user should remain on the first view with the progress bar made visible (I have implemented.)
  3. In the background the search should be making a async call to the DB. (Implemented)
  4. Once the result is back from the service, the view should change to the second view with the result. (I have not been able to implement this)

How do I implement step 4 behavior?

H A
  • 1,251
  • 2
  • 24
  • 39

1 Answers1

0

There are several different ways that you could make your call to the service asynchronous. Of the available options, I would recommend either using a BackgroundWorker, which handles most of the dirty work for you, or use the Task, which is new to .NET 4.5.

For BackgroundWorker, you can find a simple example in this answer, and you'll also find many more examples by searching.

For Task, you can read about it on MSDN here, and find many examples with a simple web searche.

Community
  • 1
  • 1
Brian S
  • 5,675
  • 1
  • 22
  • 22