如何调用wcf服务中定义的进度条

本文关键字:定义 服务 wcf 何调用 调用 | 更新日期: 2023-09-27 18:17:10

我有一个客户端(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);}

如何调用wcf服务中定义的进度条

你需要异步调用你的web服务。还需要soap客户端对此进行处理。您可以使用下载进度功能来实现此功能。

你可以查看这篇文章。

http://shenoyatwork.blogspot.com.tr/2006/10/showing-download-progress-with-net.html