Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8712713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:09:55+00:00 2026-06-13T05:09:55+00:00

On the selection changed event I am accessing the data from one of my

  • 0

On the selection changed event I am accessing the data from one of my tables. But the “Exception has been thrown by the target of an invocation” is thrown.

var query = conn.Table<auto_fares>().Where(x => x.city == cbCity.SelectedItem);
var result = await query.ToListAsync();
foreach (var item in result)
{
    txtDistance.Text = item.min_km.ToString();
    lblDayFare.Text = item.min_fare.ToString();
    lblNightFare.Text = item.night_charges.ToString();
}

After adding the Dispose statement i am getting the following error as
“The await operator can only be used within an async lamhda expression. Consider making this lamhda expression with the ‘async’ modifier.”

How can I solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:09:56+00:00Added an answer on June 13, 2026 at 5:09 am

    Try re-writing your code like this:

    var selectedCity = cbCity.SelectedItem;
    var query = conn.Table<auto_fares>().Where(x => x.city == selectedCity);
    var result = await query.ToListAsync();
    foreach (var item in result)
    {
        txtDistance.Text = item.min_km.ToString();
        lblDayFare.Text = item.min_fare.ToString();
        lblNightFare.Text = item.night_charges.ToString();
    }
    

    You’re trying to access a UI component (cbCity.SelectedItem) from a non-UI thread (await query.ToListAsync() )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listbox with several items . And the selection changed event has
In the code below, the datagridview1_SelectionChanged event which fires after the selection has been
I get data from asynchronous method. E.g i have two ListBox .When selection changed
So I have a selection list, and if the default value hasn't been changed
I need to have selection changed event inside a listbox itemtemplate. My listbox consists
The OnItemSelectedListener event handler gets called both when a spinner selection is changed programmatically,
I have a datagrid with 2 combobox columns. I wrote selection changed event for
Hai am using telerik wpf grid in grid selection change event am getting the
I have a QTableView that I need to get the selectionChanged event from. I
I have a UISegmentedControl whose Value changed event is wired up in Interface Builder

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.