2013-02-23 56 views
1

當應用程序啓動時,它將運行DispatcherTimer。每10秒鐘,它將運行running()函數,函數running()消耗一個webservice並運行得非常好。當系統無法獲得Web服務時,它會彈出「System.timeOut異常」。如何解決異常?類型爲「System.timeOut異常」的未處理異常

感謝您的幫助您可以提供!

private void running() 
    {  
     ServiceReference1.WebServiceSoapClient test = new ServiceReference1.WebServiceSoapClient(); 

     test.ReadTotalOutstandingInvoiceCompleted += new EventHandler<ServiceReference1.ReadTotalOutstandingInvoiceCompletedEventArgs>(serviceClient); 

     test.ReadTotalOutstandingInvoiceAsync(); 
    } 

private void serviceClient(object sender, ReadTotalOutstandingInvoiceCompletedEventArgs e) 

    { 
     tbTesting.Text = e.Result.ToString(); 

     tbTextbox2.Text = "You have " + tbTesting.Text + " Invoice !!"; 
     ... 
     MessageBox.Show("You have " + tbTesting.Text + " new Invoice" +Environment.NewLine+ Environment.NewLine+ DateTime.Now, "Invoice", MessageBoxButton.OK); 
     ... 
     } 

在reference.cs

public string EndReadTotalOutstandingInvoice(System.IAsyncResult result) { 

     object[] _args = new object[0]; 
     string _result = ((string)(base.EndInvoke("ReadTotalOutstandingInvoice", _args, result))); 
     return _result; 
    } 

回答

1

這只是告訴你,無論web服務做已超時且可能是不可用的。也很難說出你的意思是「解決例外」,如果web服務不可用,那麼你可能無能爲力。

+0

如果有消息框?當用戶點擊ok按鈕時,系統將嘗試訪問web服務。如何應用此? – likewer 2013-02-23 04:17:36

+0

@像什麼? – user2038443 2013-02-23 04:19:30

+0

虐待幫助你的問題,但我不寫你的代碼給你。 – user2038443 2013-02-23 04:29:34