Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
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.
XML
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.
Posted
Updated 24-Jul-14 2:22am
v2

1 solution

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

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900