私はデータベースと非同期プログラミングにはかなり新しいです。私は最終的に何百もの顧客とおそらく何千ものトランザクションを持つPOSアプリケーションを作っています。顧客の検索や前のチケットの検索をしたいときは、プログラムが結果を待っているのを待ちたくない。私はこれと同様に構成され、ボイドのメソッドを持っている私のプログラムを通してUWPでSQlite非同期を作成するには?
private void searchCritiria_TextChanging(TextBox sender, TextBoxTextChangingEventArgs args)
{
FilteredCustomer.Clear();
if(searchCritiria.Text.Length >= 3)
{
SQLiteConnection dbConnection = new SQLiteConnection("Customers.db");
string sSQL = null;
sSQL = @"SELECT [first],[last],[spouse],[home],[work],[cell] FROM Customers";
ISQLiteStatement dbState = dbConnection.Prepare(sSQL);
while (dbState.Step() == SQLiteResult.ROW)
{
string sFirst = dbState["first"] as string;
string sLast = dbState["last"] as string;
string sSpouse = dbState["spouse"] as string;
string sHome = dbState["home"] as string;
string sWork = dbState["work"] as string;
string sCell = dbState["cell"] as string;
//Load into observable collection
if (searchType.SelectedIndex == 0)//name search
{
if(sFirst.Contains(searchCritiria.Text) || sLast.Contains(searchCritiria.Text) || sSpouse.Contains(searchCritiria.Text))
FilteredCustomer.Add(new Customer {first = sFirst, last = sLast, spouse = sSpouse, home = sHome, work = sWork, cell = sCell});
}
else//number search
{
if(sWork.Contains(searchCritiria.Text)|| sHome.Contains(searchCritiria.Text) || sCell.Contains(searchCritiria.Text))
FilteredCustomer.Add(new Customer { first = sFirst, last = sLast, spouse = sSpouse, home = sHome, work = sWork, cell = sCell });
}
}
}
}
:ここ
は、検索結果を表示する方法です。
この問題を解決する方法がわかりません。私はいくつかの研究をしましたが成功しませんでした。どんなアドバイスも大歓迎です!
async内でコードを実行する 'await Task.Run(()=> {});'を使用してください。 – Krishna