вызовите метод Async несколько раз в Silverlight - PullRequest
0 голосов
/ 16 марта 2011

Привет, я вызываю метод Async с другим значением параметра несколько раз, давая тот же результат в завершенном событии.

client.ListAllLookupValuesByTypeCompleted += client_ListAllAddressFormatCompleted;
client.ListAllLookupValuesByTypeAsync("AddressFormat");

client.ListAllLookupValuesByTypeCompleted += client_ListAllPhoneFormatCompleted;
client.ListAllLookupValuesByTypeAsync("PhoneFormat");



void client_ListAllAddressFormatCompleted(object sender, ListAllLookupValuesByTypeCompletedEventArgs e)
        {
            cmbAddressFormat.ItemsSource = e.Result;
        }


void client_ListAllPhoneFormatCompleted(object sender, ListAllLookupValuesByTypeCompletedEventArgs e)
        {
            cmbPhonePrintFormat.ItemsSource = e.Result;
        }

, пожалуйста, помогите мне.Спасибо.

1 Ответ

1 голос
/ 16 марта 2011

Вы можете создать новый экземпляр client.

...
var client = new XyzClient();
client.ListAllLookupValuesByTypeCompleted += client_ListAllAddressFormatCompleted;
client.ListAllLookupValuesByTypeAsync("AddressFormat");

client = new XyzClient();
client.ListAllLookupValuesByTypeCompleted += client_ListAllPhoneFormatCompleted;
client.ListAllLookupValuesByTypeAsync("PhoneFormat");
...


void client_ListAllAddressFormatCompleted(object sender, ListAllLookupValuesByTypeCompletedEventArgs e)
{
    cmbAddressFormat.ItemsSource = e.Result;
}


void client_ListAllPhoneFormatCompleted(object sender, ListAllLookupValuesByTypeCompletedEventArgs e)
{
   cmbPhonePrintFormat.ItemsSource = e.Result;
}

Другим решением было бы сделать второй вызов в обработчике первого (возможно, в любом случае, создав новый экземпляр клиента).

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...