我正在嘗試調用/推送一個半大的tiff和一個Gal文件到java web服務。 該平臺是Visual Studio 2013,C#windows窗體應用程序。如何從C#winform異步調用Soap/mtom Web服務
我指向WSDL文件,「平臺」正在爲我生成一個服務引用類。 這些都是從我這裏抽象出來的,這是一件好事,因爲我是這個競技場的新手。 我離開了「生成基於任務的代碼」,我得到了一個addSample和addSampleAsync方法。
我填充類字段並將代碼向上推。
addSample代碼工作正常,但阻止用戶界面。
異步代碼addSampleAsync也起作用,位比較慢並且不完全異步。 addSampleAsync將UI鎖定大約一半的處理時間,並且對fncTestUpload的函數調用在相同的時間段內不會返回。
//Dimensioned at class level
//private static addSamplePortClient Service = new addSamplePortClient();
//private static addSampleResponse Myresult = new addSampleResponse();
//ThisRequest is the WSDL modeled class object.
//This code works, but is slow, 30 seconds on wifi
ResponseType Myresult = Service.addSample(ThisRequest.Request);
MessageBox.Show(Myresult.Message + Myresult.Code);
//This code locks up the UI for about 15 - 20 seconds then takes another 15 to display the messagebox
fncTestUpload(ThisRequest);
async void fncTestUpload(addSampleRequest SentRequest)
{
Myresult = await Service.addSampleAsync(SentRequest.Request);
MessageBox.Show(Myresult.Response.Message + " - " + Myresult.Response.Code);
}
我做出了迴應,在調用fncTestUpload,它調用一個異步函數時,原以爲會立即返回功能做它的東西,希望對象的類級變量。直到15秒後它纔會返回。
我已經花了幾個小時搜索這個,並沒有找到任何答案,爲什麼addSampleAsync工作不像廣告。
微軟的教程也可以用Dilbert的Elbonian編寫。我無法跟隨他們,也沒有發現他們有幫助,所以請不要指引我。
與論壇網站不同,我們不使用「謝謝」或「任何幫助表示讚賞」,或在[so]上簽名。請參閱「[應該'嗨','謝謝',標語和致敬從帖子中刪除?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be -removed - 從 - 個)。 –