I have a long running WCF service and a client that consumes it via WPF. Am using a Progress Bar to notify the client of the percentage completion for a particular process (a method in WCF: I need to be able to display the percentage based on the looping counter in the service)
I have used Background Worker to display progress percentage but it does not display the progress correctly. (displays just 0 and 100 not the in between values) Everything works fine in DEBUG mode but not in RELEASE mode! (Progress bar is updated sequentially in DEBUG mode)
I tried using callbacks/wsDualHttpBinding but have some difficulty in getting this incorporated for all clients. So, had to drop this option.
working on async/await. I have googled quite a few links but nothing helps with my problem.
Please guide me on how to get the current/running value from a method that is not complete yet from a WCF service so I could populate the progress bar percentage based on this value. (in between values)
P.S: WCF service uses wsHttpBinding
sample code below:
public Progress(){// Start the BackgroundWorker. myBGWorker.WorkerReportsProgress = true; myBGWorker.WorkerSupportsCancellation = false; myBGWorker.DoWork += myBGWorker_DoWork; myBGWorker.ProgressChanged += myBGWorker_ProgressChanged;}public void ShowProgress(){ myBGWorker.RunWorkerAsync();}private void myBGWorker_DoWork(object sender, DoWorkEventArgs e){// fetches a static value from the service string value = _client.Progress();int p=0;for (int i = 1; i <= 100; i++){// Report progress. p = Convert.ToInt32(_client.Progress()); _logger.Debug("Progress5:" + p.ToString()); myBGWorker.ReportProgress(p, i);}}private void myBGWorker_ProgressChanged(object sender, ProgressChangedEventArgs e){this.Dispatcher.BeginInvoke(new Action(delegate{ progressBar1.Value = e.ProgressPercentage;}), DispatcherPriority.ContextIdle);}