如何在silverlight中使用Asynchronous完成的结果 [英] How to use Asynchronous completed result in silverlight

查看:50
本文介绍了如何在silverlight中使用Asynchronous完成的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用异步调用,我想使用Asynchronous完成的结果。如果它真的我会移动,如果它不是我不需要执行代码



I'm using asynchronous calls,I wanna use Asynchronous completed result.If its true i will move if its not I won't need to execute the code

protected void btnInitiate_Click(object sender, System.Windows.RoutedEventArgs e)
     {
       

if (txtNewMaterialCode.Text != string.Empty)
              {

                  ObservableCollection<Paramaters> parm = new ObservableCollection<Paramaters>();
                  parm.Add(ReturnParameters("@OPERATION", "1"));
                  parm.Add(ReturnParameters("@PDV_MATERIAL_CODE", txtNewMaterialCode.Text.Trim()));
                  var Proxy = WCF.GetService();
                  Proxy.GetDataSetProcCompleted += new EventHandler<GetDataSetProcCompletedEventArgs>(CheckmaterialCode);
                  Proxy.GetDataSetProcAsync("USP_PRODUCT_MASTER", parm.ToArray(), "userState");

              }



//这是依赖于我的异步调用结果的代码。如果它是真的我会执行这个,否则我跳过这段代码执行。


//This is the code which depends on my asynchronous call result.If its true i will execute this otherwise I skip this code to execute.

stpnlControls.Visibility = Visibility.Collapsed;
stpnlConformation.Visibility =
txbProductInformation.Visibility = Visibility.Visible;



但这里究竟发生了什么,它首先在这里执行所有代码在它转移到异步调用之后。所以我不希望基于结果发生我需要选择进一步执行或跳过执行。


But what exactly happening here is,it first executes all the code here and after it moves to asynchronous call.So I dn't wanna that to happen based on result I need a choice to execute further or skip to execute.

推荐答案

添加以下代码:

Add the following code :
void CheckmaterialCode (object sender,GetDataSetProcCompletedEventArgs e )
{

    if(e.Error == null)
    {
      if(e.Result)
        {
          stpnlControls.Visibility = Visibility.Collapsed;
          stpnlConformation.Visibility =
          txbProductInformation.Visibility = Visibility.Visible
        }
    }
}


这篇关于如何在silverlight中使用Asynchronous完成的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆