none
IsIndeterminate ProgressBar in WPF RRS feed

  • Question

  • Hello

    I have got a progressbar which i would like to display when my application is calling multiple webservices. I have set the IsIndeterminate property of the Progressbar to true. The progressbar never appeared when I set visibilty to Visible. This is because, i call the webmethods immediately after. Which hangs the application.

    I had to use a dispatcher



    Code Snippet

    Progressbar1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Loaded,
                        (MyDelegate)delegate { });



    The actual problem im facing, is the progressbar doesnt animate. Iv tried placing it in a new thread, But that did not work.

    I would appreciate help on this.
    Thursday, April 24, 2008 9:00 AM

Answers

  • You should only be using Dispatcher.BeginInvoke to update UI objects.

    By calling Dispatcher.BeginInvoke in your worker thread you are getting your WebMethods executed on the UI thread.

     

    --Ifeanyi Echeruo [MSFT]
    Thursday, April 24, 2008 10:38 PM

All replies

  • You need to actually be calling your webservices on another thread. Don't try and create the progressbar on another thread.

     

    Thursday, April 24, 2008 9:10 AM
  • I have tried to do that..

    code

    Code Snippet

                      ThreadStart tStart = new ThreadStart(delegate()
                        {
                            webServiceCall();
                        });

                        Thread webThread = new Thread(tStart);

                        webThread.Start();



            void webServiceCall()
            {
                this.Dispatcher.BeginInvoke(DispatcherPriority.Normal,(System.Threading.ThreadStart) delegate()
                {
                    //WebMethods
                });
            }


    So the webservice calls are running on a different thread. Yet the Progressbar still doesnt animate.
    Thursday, April 24, 2008 9:45 AM
  • Im using Enterprise Library 3 CAB, with WPF.
    Thursday, April 24, 2008 9:50 AM
  • You should only be using Dispatcher.BeginInvoke to update UI objects.

    By calling Dispatcher.BeginInvoke in your worker thread you are getting your WebMethods executed on the UI thread.

     

    --Ifeanyi Echeruo [MSFT]
    Thursday, April 24, 2008 10:38 PM
  • Thank you.

    I realized my mistake. The reason for me placing the webmethods in the Dispatcher.BeginInvoke was due to the fact that the webservices change an observable collection which is bound to the UI(custom GridView). I managed to find a workaround.
    Friday, April 25, 2008 9:44 AM