views:

138

answers:

0

Hi,

I am facing the issue in updating the Database during a browser close in the Application_Exit method. Since I cannot call a webmethod in this event to updated the DB, I'm trying for a workaround where I call another simple Silverlight Application for the sole purpose of performing the DB update.

The issue is that when I make the Async call to the method abcClient.UpdateDataBaseAsync(id, status, stopTime) in my StopTimers function, it doesn't actually call the Webmethod and the value doesnt get updated in the DB.

Any suggestions please?

// First Silverlight Application's Exit method

        private void Application_Exit(object sender, EventArgs e)
        {
           SecondApplication.SecondAppMainPage objSecondApp = new SecondApplication.MainPage("10", "stop", System.DateTime.Now);
        }

// Second Silverlight Application

public partial class SecondAppMainPage : UserControl
{
    ABCServiceSoapClient abcClient = new ABCServiceSoapClient();
    public MainPage()
    {
        InitializeComponent();
    }
    public MainPage(string id, string status, DateTime stopTime)
    {
        InitializeComponent();
        StopTimers(id, status, stopTime);
    }

    public void StopTimers(string id, string status , DateTime stopTime) 
    {
        abcClient.UpdateDataBaseAsync(id, status, stopTime);
        /// A call is being made to this Async function but the database update isn't                    
        /// happening.
    }
}

Regards, Syed.