2012-03-14 28 views
0

我有一個使用了一系列的數據庫調用gathre的按鈕和列表框......常見的內容的信息的Silverlight應用程序....Silverlight的 - 網絡服務來獲取連接字符串

現在客戶想使用一個web服務來返回連接字符串。

應用程序時的連接字符串在web.config文件被加載運行正常,但是當我嘗試加載從Web服務連接字符串,它導致應用程序實際上是失敗的。

我只能假設web服務即返回連接字符串之前不會完成該填充基於連接字符串控制的其他線程。

問題是這樣的....在Silverlight應用程序,我想連接字符串Web服務調用之前要填充的控件完成。

會在哪裏我放在webserevice調用,以確保它完成,ConnectionString的值實際上有一個值?

感謝 託尼

回答

0

我覺得這是你所需要的:

public App() 
{ 
    this.Startup += this.Application_Startup; 
    this.Exit += this.Application_Exit; 
    this.UnhandledException += this.Application_UnhandledException; 

    InitializeComponent(); 
} 

private void Application_Startup(object sender , StartupEventArgs e) 
{ 
    var client = new MyClient(); 
    client.GetConnectionStringCompleted += (clientSender, clientEventArgs) => 
    { 
    if (clientEventArgs.Error != null) 
    { 
     myConnectionString = clientEventArgs.Result; 
    } 
    this.RootVisual = new MainPage(); 
    }; 
    client.GetConnectionStringAsync(); 
}