Label.Text refresh .... ?

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

    #1

    Label.Text refresh .... ?

    When the user clicks the download button I am changing the text of a label
    control and do download operation.

    The download part of the code makes the application appears like stop
    responding.

    My question is how to refresh the windows form right after changing the
    label text.

    I am talking about VB.Net desk top application developed using .Net
    Framework 1.1

    Thanks,

    Smith


  • Crouchie1998

    #2
    Re: Label.Text refresh .... ?

    I am not sure if I really understand your post, but if you click a button to
    download something & then try to update a label. Am I right? If so, run your
    download from a new thread & then update your label text

    Imports System.Threadin g

    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button1.Click
    Dim t As Thread = New Thread(AddressO f Download)
    t.Start()
    Label1.Text = "Download Started"
    End Sub

    Private Sub Download()
    ' Do the download part here
    End Sub

    I hope this helps

    Crouchie1998
    BA (HONS) MCP MCSE


    Comment

    • Zoury

      #3
      Re: Label.Text refresh .... ?

      Hi !
      [color=blue]
      > The download part of the code makes the application appears like stop
      > responding.
      > My question is how to refresh the windows form right after changing the
      > label text.[/color]

      You can either call Application.DoE vents() right after you change the
      Label.Text property or make the download part in an other thread which
      should make the download completely invisible to the user (the app won't
      freeze or something).

      --
      Best Regards
      Yanick


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Label.Text refresh .... ?

        "Crouchie19 98" <crouchie1998@s pamcop.net> schrieb:[color=blue]
        >I am not sure if I really understand your post, but if you click a button
        >to
        > download something & then try to update a label. Am I right? If so, run
        > your
        > download from a new thread & then update your label text[/color]

        In addition to your reply:

        Note that some download methods in the .NET Framework provide support for
        asynchronous operation. Otherwise, as you say, a worker thread is the way
        to go. However, it's not allowed to access Windows Forms controls from
        within the thread, so if you want to access the UI from within the thread,
        you'll have to use interop techniques:

        Multithreading in Windows Forms applications
        <URL:http://dotnet.mvps.org/dotnet/faqs/?id=multithread ing&lang=en>

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

        Comment

        • Allen Smith

          #5
          Re: Label.Text refresh .... ?

          Thanks to all of you,
          Your reply helped me.
          Smith

          "Zoury" <yanick_lefebvr e at hotmail dot com> wrote in message
          news:Ocp0Xh5aFH A.1312@TK2MSFTN GP09.phx.gbl...[color=blue]
          > Hi !
          >[color=green]
          > > The download part of the code makes the application appears like stop
          > > responding.
          > > My question is how to refresh the windows form right after changing the
          > > label text.[/color]
          >
          > You can either call Application.DoE vents() right after you change the
          > Label.Text property or make the download part in an other thread which
          > should make the download completely invisible to the user (the app won't
          > freeze or something).
          >
          > --
          > Best Regards
          > Yanick
          >
          >[/color]


          Comment

          Working...