Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > General Discussions > asyncronous save

Not answered asyncronous save

Feed from this thread
  • Suraj avatar

    Posted on Jan 18, 2012 (permalink)

    i am using the following code to save the data.

    button click()
    {
    clientLeave.SaveLeaveApplicationCompleted += new EventHandler<SaveLeaveApplicationCompletedEventArgs>(clientLeave_SaveLeaveApplicationCompleted1);
                    clientLeave.SaveLeaveApplicationAsync(item);
    }

    void clientLeave_SaveLeaveApplicationCompleted1(object sender, SaveLeaveApplicationCompletedEventArgs e)
            {
                if (e.Result > -1)
                {
                   
                        MessageBox.Show("Record Saved Successfully", Declares.MsgTitle, MessageBoxButton.OK);
     
                }
            }

    Note:
    If i save the second record, message box is showing twice & thrice for 3rd record and so on...

    Reply

  • Stanescu Mihai avatar

    Posted on Feb 6, 2012 (permalink)

    Haven't tried it but I think your problem is that you don't unsubscribe from the SaveLeaveApplicationCompleted event, and every time you save again it subscribes again and again.
    Try putting this to unsubsribe from the event:
    clientLeave.SaveLeaveApplicationCompleted -= new EventHandler<SaveLeaveApplicationCompletedEventArgs>(clientLeave_SaveLeaveApplicationCompleted1); 
       in the body of void clientLeave_SaveLeaveApplicationCompleted1 ().
    Either this or subscribe to the SaveLeaveApplicationCompleted event outside of the button click.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > General Discussions > asyncronous save