Marquee Style ProgressBar

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JB

    Marquee Style ProgressBar

    Hi All,

    I have a Windows Form application that shows a "please wait" form
    while I query a database for various information.
    I display my form using Show, then run my DB query, then Close the
    form at the end.

    To make it look even nicer I placed a marquee style Progress Bar on my
    form.
    It works exactly the same way, but the marquee style progress bar
    doesn't move at all while I'm running my DB query, which defeats the
    purpose. If I don't close my form straight away after my DB query
    returns, the progress bar starts moving.

    It looks like the DB query thread is taking over the UI threadand
    preventing my progress bar to move. However I was under the (naive)
    impression that a marquee style progress bar was "thread independent"
    and capable of moving as soon as displayed on a form (almost like an
    animated Gif). Can somebody tell me if I can get the progress bar to
    move while running the DB query without having to run the DB query in
    a different thread.

    Thanks
    JB
  • JB

    #2
    Re: Marquee Style ProgressBar Not Moving

    On 2 Jun, 17:19, JB <jb.bross...@gm ail.comwrote:
    Hi All,
    >
    I have a Windows Form application that shows a "please wait" form
    while I query a database for various information.
    I display my form using Show, then run my DB query, then Close the
    form at the end.
    >
    To make it look even nicer I placed a marquee style Progress Bar on my
    form.
    It works exactly the same way, but the marquee style progress bar
    doesn't move at all while I'm running my DB query, which defeats the
    purpose. If I don't close my form straight away after my DB query
    returns, the progress bar starts moving.
    >
    It looks like the DB query thread is taking over the UI threadand
    preventing my progress bar to move. However I was under the (naive)
    impression that a marquee style progress bar was "thread independent"
    and capable of moving as soon as displayed on a form (almost like an
    animated Gif). Can somebody tell me if I can get the progress bar to
    move while running the DB query without having to run the DB query in
    a different thread.
    >
    Thanks
    JB

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Marquee Style ProgressBar

      "JB" <jb.brossard@gm ail.comschrieb:
      I have a Windows Form application that shows a "please wait" form
      while I query a database for various information.
      I display my form using Show, then run my DB query, then Close the
      form at the end.
      >
      To make it look even nicer I placed a marquee style Progress Bar on my
      form.
      It works exactly the same way, but the marquee style progress bar
      doesn't move at all while I'm running my DB query, which defeats the
      purpose. If I don't close my form straight away after my DB query
      returns, the progress bar starts moving.
      >
      It looks like the DB query thread is taking over the UI threadand
      preventing my progress bar to move. However I was under the (naive)
      impression that a marquee style progress bar was "thread independent"
      and capable of moving as soon as displayed on a form (almost like an
      animated Gif). Can somebody tell me if I can get the progress bar to
      move while running the DB query without having to run the DB query in
      a different thread.
      I suggest to perform the query in the background thread. It's never a good
      idea to block the main UI thread because this will prevent user interaction
      (closing forms, etc.).

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      • Jack Jackson

        #4
        Re: Marquee Style ProgressBar

        On Mon, 2 Jun 2008 09:19:05 -0700 (PDT), JB <jb.brossard@gm ail.com>
        wrote:
        >Hi All,
        >
        >I have a Windows Form application that shows a "please wait" form
        >while I query a database for various information.
        >I display my form using Show, then run my DB query, then Close the
        >form at the end.
        >
        >To make it look even nicer I placed a marquee style Progress Bar on my
        >form.
        >It works exactly the same way, but the marquee style progress bar
        >doesn't move at all while I'm running my DB query, which defeats the
        >purpose. If I don't close my form straight away after my DB query
        >returns, the progress bar starts moving.
        >
        >It looks like the DB query thread is taking over the UI threadand
        >preventing my progress bar to move. However I was under the (naive)
        >impression that a marquee style progress bar was "thread independent"
        >and capable of moving as soon as displayed on a form (almost like an
        >animated Gif). Can somebody tell me if I can get the progress bar to
        >move while running the DB query without having to run the DB query in
        >a different thread.
        >
        >Thanks
        >JB
        Unless you explicitly create another thread to do the DB query, it
        runs on the UI thread. Likewise the ProgressBar, being a UI control,
        runs totally in the UI thread.

        To keep the ProgressBar running you need to run the DB query on
        another thread. BackgroundWorke r works well for this kind of
        operation.

        Comment

        • kimiraikkonen

          #5
          Re: Marquee Style ProgressBar

          On Jun 2, 7:19 pm, JB <jb.bross...@gm ail.comwrote:
          Hi All,
          >
          I have a Windows Form application that shows a "please wait" form
          while I query a database for various information.
          I display my form using Show, then run my DB query, then Close the
          form at the end.
          >
          To make it look even nicer I placed a marquee style Progress Bar on my
          form.
          It works exactly the same way, but the marquee style progress bar
          doesn't move at all while I'm running my DB query, which defeats the
          purpose. If I don't close my form straight away after my DB query
          returns, the progress bar starts moving.
          >
          It looks like the DB query thread is taking over the UI threadand
          preventing my progress bar to move. However I was under the (naive)
          impression that a marquee style progress bar was "thread independent"
          and capable of moving as soon as displayed on a form (almost like an
          animated Gif). Can somebody tell me if I can get the progress bar to
          move while running the DB query without having to run the DB query in
          a different thread.
          >
          Thanks
          JB
          While querying the DB, probably your UI thread is being blocked,
          that's why you need to use BackgroundWorke r component to show progress
          bar marquee animation during the operation asyncronusly.

          Thanks,

          Onur Güzel

          Comment

          • davidkurniawan

            #6
            Re: Marquee Style ProgressBar

            Try Using BackgroundWorke r Component.:

            Private Sub LoginBtn_Click( ByVal sender As System.Object, ByVal e
            As System.EventArg s) Handles LoginBtn.Click
            ProgressBar.Sty le = ProgressBarStyl e.Marquee
            BackWorker.RunW orkerAsync()
            End Sub

            Private Sub BackWorker_DoWo rk(ByVal sender As System.Object, ByVal
            e As System.Componen tModel.DoWorkEv entArgs) Handles BackWorker.DoWo rk

            doConnect()

            End Sub

            Private Sub BackWorker_RunW orkerCompleted( ByVal sender As Object,
            ByVal e As System.Componen tModel.RunWorke rCompletedEvent Args) Handles
            BackWorker.RunW orkerCompleted
            ProgressBar.Sty le = ProgressBarStyl e.Blocks
            If Koneksi.StatusK oneksi = "Terkoneksi " Then Connected()
            End Sub

            Comment

            • JB

              #7
              Re: Marquee Style ProgressBar

              Hi All,

              Thanks for all your suggestions.
              I did implement a BackgroundWorde r solution and it wasn't that
              complicated after all.

              JB

              davidkurniawan wrote:
              Try Using BackgroundWorke r Component.:
              >
              Private Sub LoginBtn_Click( ByVal sender As System.Object, ByVal e
              As System.EventArg s) Handles LoginBtn.Click
              ProgressBar.Sty le = ProgressBarStyl e.Marquee
              BackWorker.RunW orkerAsync()
              End Sub
              >
              Private Sub BackWorker_DoWo rk(ByVal sender As System.Object, ByVal
              e As System.Componen tModel.DoWorkEv entArgs) Handles BackWorker.DoWo rk
              >
              doConnect()
              >
              End Sub
              >
              Private Sub BackWorker_RunW orkerCompleted( ByVal sender As Object,
              ByVal e As System.Componen tModel.RunWorke rCompletedEvent Args) Handles
              BackWorker.RunW orkerCompleted
              ProgressBar.Sty le = ProgressBarStyl e.Blocks
              If Koneksi.StatusK oneksi = "Terkoneksi " Then Connected()
              End Sub

              Comment

              Working...