2016-04-13 16 views
1

サービスコールが行われたときにProgressBarを表示したい。 のProduct.xmlWindowsのサービスコールでアプリケーションが保存されているときにProgressBarボタンが表示されない

<ProgressBar Name="loading1" Visibility="Collapsed" IsIndeterminate="True" HorizontalAlignment="Left" Height="50" Width="535" VerticalAlignment="Center" Background="White" Grid.Row="1" Margin="0,311,0,310"/> 

Product.xml.cs

loading.Visibility = Visibility.Visible; //loading start 
getAllProductDetails(); //contain service call and bind data in list 
loading.Visibility = Visibility.Collapsed; //loading finish 

ロードは "getAllProductDetails()" コールの前に開始する必要があり、それはかつて "getAllProductDetails()" 仕上げを完了する必要があります。

私もawait Task.Run(() => getAllProductDetails());を使用している場合は、次の行 "await Task.Run(() => getAllProductDetails());"の実行を続けます。 "getAllProductDetails()"コールが完了するまで待つ必要があります。

誰かが私がここで紛失していることを教えてもらえますか?

+0

'getAllProductDetails()'のコードは何ですか? –

+1

@EldarDordzhiev "private非同期void getAllProductDetails()"サーバとバインドリストからデータを取得するサービスコールが含まれています。 –

+0

何も間違っていないと仮定すると、 'getAllProductDetails()'の戻り値を 'Task'に変更する必要があります。 –

答えて

0
代わり void

private async Task getAllProductDetails() 
{ 
    // Body 
} 

Taskを返し、その後、任意の非同期機能を使用すると、実行の完了を待つことができないvoidを返す場合、この

loading.Visibility = Visibility.Visible; //loading start 
await getAllProductDetails(); 
loading.Visibility = Visibility.Collapsed; //loading finish 

のように呼び出すために、あなたのgetAllProductDetails()を変更

+0

別の呼び出し " getAllProductDetails()内の "async Task"? –

+0

あなたもそれを待っている限り動作します –

+0

私は別の問題に直面しています。私は別のチケットを追加しました。 http://stackoverflow.com/questions/36613869/how-to-handle-event-raise-in-await-method-to-manage-progressbar-in-windows-store –

関連する問題