[英]How to call progress bar defined in wcf service - c#
我有一個客戶端(WinForms應用程序)/服務器(WCF服務),在其中執行一些復雜的邏輯,該邏輯將數據包寫入遠程主機-此過程大約需要20分鍾才能寫入到特定點,但未完成。 因此,我想以進度條的形式顯示進度,並嘗試從上次停止在客戶端應用程序中繼續執行。
//Service:
public class ServiceImplementation: IServiceInterface{
ProgressBar pgBar = new ProgressBar();
public void complexFunction(byte[] data_to_send, UInt32 start_addr){
pgBar.Maximum = data_to_send.Length;
for(int i = 0; i < data_to_send.Length; i += 64){
//do some logic
}
pgBar.Value = i;
}
}
//Client
private void btnProgComplexFunction_Click(object sender, EventArgs e){
callComplexFunction
}
void callComplexFunction(){
ServiceImplementation.ServiceImplementationClient proxyInstance = new
ServiceImplementation.ServiceImplementationClient();
//I attempted doing the following but obviously it doesn't work because progress bar returns an integer (e.g pgBar.Value = 100;). The problem lies here. I have been cracking my skull for two days straight
pgBar.Value = proxyInstance.complexFunction(data_to_send, start_addr);}
您需要異步調用Web服務。 還需要給客戶肥皂。 您可以使用下載進度功能來實現。
您可以查看這篇文章。
http://shenoyatwork.blogspot.com.tr/2006/10/showing-download-progress-with-net.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.