2017-02-03 4 views
1

データテーブルを埋めている間に 'データの取得'のようなメッセージを表示したいとします。それを起こす機会はありますか?データテーブルを埋めるときに 'Retrieving Data'メッセージを表示

ここに私のコードは、データテーブルを埋めるです。

public void getAlertGrid() 

    { 
      odaAlert = new OracleDataAdapter(getAlert, oradb); //odaAlert is Adapter 
      odaAlert.Fill(dtAlert); // dtAlert is Datatable 
      ugAlert.DataSource = dtAlert; 
    } 
+0

使用 'Backgroundworker'または' Thread' –

+0

@IkramTurgunbaevこんにちは:あなたのgetAlertGridメソッドを呼び出す代わりに、このような何かを行います。仕事はどうですか? –

+0

はい、あなたもタスクを使用することができます –

答えて

0

@IkramTurgunbaevは、データを非同期的に読み込んでステータスバーを更新する必要があると述べています。

private void MethodThatCallsGetAlertGrid() 
{ 
    // Show the progress bar and set the style of progress bar to Marquee. This will show continiously scrolling block across progress bar, as you cannot know the current progress percent 
    this.progressBar1.Visible = true; 
    this.progressBar1.Style = ProgressBarStyle.Marquee; 

    // Start loading the data source async 
    Task.Factory.StartNew(() => 
     this.getAlertGrid()) 
    .ContinueWith((antecedent) => 
    { 
     // Set data source on UI thread. Remove the same row from your getAlertGrid method 
     ugAlert.DataSource = dtAlert; 

     // Hide the progress bar 
     this.progressBar1.Visible = false; 
    }, TaskScheduler.FromCurrentSynchronizationContext()); 
関連する問題