blinking label

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

    #1

    blinking label

    How can i make a blinking label ? Is this possible ?


  • lord.zoltar@gmail.com

    #2
    Re: blinking label

    On Feb 8, 12:14 pm, "giannis" <zzzinob...@fre email.grwrote:
    How can i make a blinking label ? Is this possible ?
    Never tried this, but you could have a timer, and for each tick event,
    change the visibility (or colour, or whatever) of the label in
    question.

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: blinking label

      <lord.zoltar@gm ail.comschrieb:
      >How can i make a blinking label ? Is this possible ?
      >
      Never tried this, but you could have a timer, and for each tick event,
      change the visibility (or colour, or whatever) of the label in
      question.
      This should work. For Windows Forms applications,
      'System.Windows .Forms.Timer' (available in the toolbox) is the right choice.

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

      Comment

      • giannis

        #4
        Re: blinking label

        Herfried K. Wagner [MVP] wrote:
        This should work. For Windows Forms applications,
        'System.Windows .Forms.Timer' (available in the toolbox) is the right
        choice.
        I wrote at the Tick event the :

        Me.Label.Visibl e = Not Me.Label.Visibl e

        but nothing happened :(


        Comment

        • Armin Zingler

          #5
          Re: blinking label

          "giannis" <zzzinobios@fre email.grschrieb
          Herfried K. Wagner [MVP] wrote:
          This should work. For Windows Forms applications,
          'System.Windows .Forms.Timer' (available in the toolbox) is the
          right choice.
          >
          I wrote at the Tick event the :
          >
          Me.Label.Visibl e = Not Me.Label.Visibl e
          >
          but nothing happened :(
          Is the line executed? Did you start the Timer (calling start method or
          setting enabled=true)? Do you execute other code while you expect the Timer
          to tick? If you do, the Timer won't tick before the code has finished it's
          job. To solve it, execute the other code in another thread. This prevents
          the main thread that also keeps the Timer ticking, from being blocked by the
          other code.


          Armin

          Comment

          • Martin H.

            #6
            Re: blinking label

            Hi,
            >I wrote at the Tick event the :
            >>
            >Me.Label.Visib le = Not Me.Label.Visibl e
            >>
            >but nothing happened :(
            >
            Is the line executed? Did you start the Timer (calling start method or
            setting enabled=true)? Do you execute other code while you expect the
            Timer to tick? If you do, the Timer won't tick before the code has
            finished it's job. To solve it, execute the other code in another
            thread. This prevents the main thread that also keeps the Timer ticking,
            from being blocked by the other code.
            also ensure that the value for the timer is not too low (keep in mind
            it's milliseconds, so a value of 1000 represents 1 second).

            Best regards,

            Martin

            Comment

            • giannis

              #7
              Re: blinking label

              the form2 have a label "please wait" that i want to blink.
              at the load event of form1 i have write :

              My.Forms.form2. Show()

              form2.Refresh()

              My.Forms.form2. Timer1.Start()

              Me.TABLETableAd apter.Fill(Me.D ATABASEDataSet. SKITSA)

              My.Forms.paraka lw.Close()

              but the label at the form2 dont blinking :(


              Comment

              • giannis

                #8
                Re: blinking label

                Me.TABLETableAd apter.Fill(Me.D ATABASEDataSet. TABLE


                Comment

                • giannis

                  #9
                  Re: blinking label

                  Me.TABLETableAd apter.Fill(Me.D ATABASEDataSet. TABLE)


                  Comment

                  • Armin Zingler

                    #10
                    Re: blinking label

                    "giannis" <zzzinobios@fre email.grschrieb
                    the form2 have a label "please wait" that i want to blink. at the
                    load event of form1 i have write :
                    >
                    My.Forms.form2. Show()
                    >
                    form2.Refresh()
                    >
                    My.Forms.form2. Timer1.Start()
                    >
                    Me.TABLETableAd apter.Fill(Me.D ATABASEDataSet. SKITSA)
                    >
                    My.Forms.paraka lw.Close()
                    >
                    but the label at the form2 dont blinking :(

                    See my explanation in my previous post. I also mentioned how to solve it.


                    Armin

                    Comment

                    • giannis

                      #11
                      Re: blinking label

                      Armin Zingler wrote:
                      See my explanation in my previous post. I also mentioned how to solve it.
                      At your previous post you say :
                      "execute the other code in another thread".
                      What means this ? Sorry but i am a newbie user
                      of Visual Studio and i dont know very well english...


                      Comment

                      • Armin Zingler

                        #12
                        Re: blinking label

                        "giannis" <zzzinobios@fre email.grschrieb
                        Armin Zingler wrote:
                        See my explanation in my previous post. I also mentioned how to
                        solve it.
                        >
                        At your previous post you say :
                        "execute the other code in another thread".
                        What means this ? Sorry but i am a newbie user
                        of Visual Studio and i dont know very well english...
                        I hope these topics are also available in your language in your local help
                        (<F1>):

                        http://msdn2.microsoft.com/en-us/lib...sx(VS.71).aspx
                        http://msdn2.microsoft.com/en-us/library/3e8s7xdd.aspx

                        In short: A process consists of at least one thread. A thread is a unit that
                        executes code. Usually you have one main thread. A thread can be a UI (user
                        interface; showing windows, accepting input) thread. This means that it has
                        a message loop. The loop is there to process all the messages that are sent
                        to the windows in the thread. Messages are keyboard or mouse messages, or
                        timer messages. You handle these message by writing event handlers, for
                        example the Timer's Tick event handler.

                        Now, if you press a button and execute the code that you've shown us, the
                        code does not return to the message loop before the code in the Click
                        handler has been finished. Consequently, the timer messages are not
                        processed before you have finished filling the dataset. The label will not
                        blink.

                        To solve this, you can create a new thread and do the work in the new
                        thread. The click event handler immedetially returns to the message loop,
                        the Timer will tick and the label will blink.

                        This takes some more work to managed the execution of multiple threads,
                        but... see the links.


                        Armin

                        Comment

                        • giannis

                          #13
                          Re: blinking label

                          The form2 have the label "please wait" and at the load event of form1 i
                          write :

                          Dim t As New System.Threadin g.Thread(Addres sOf mySub)

                          t.Start()

                          Call mySub()

                          Me.TABLETableAd apter.Fill(Me.D ATABASEDataSet. TABLE)

                          Form2.Close()

                          t.Abort()

                          where :

                          Sub mySub()

                          Form2.Show()

                          Form2.Refresh()

                          End Sub

                          but again the label dont blinking ...

                          Where is the logical error ?


                          Comment

                          • Armin Zingler

                            #14
                            Re: blinking label

                            "giannis" <zzzinobios@fre email.grschrieb
                            The form2 have the label "please wait" and at the load event of
                            form1 i write :
                            >
                            Dim t As New System.Threadin g.Thread(Addres sOf mySub)
                            >
                            t.Start()
                            >
                            Call mySub()
                            >
                            Me.TABLETableAd apter.Fill(Me.D ATABASEDataSet. TABLE)
                            >
                            Form2.Close()
                            >
                            t.Abort()
                            >
                            where :
                            >
                            Sub mySub()
                            >
                            Form2.Show()
                            >
                            Form2.Refresh()
                            >
                            End Sub
                            >
                            but again the label dont blinking ...
                            >
                            Where is the logical error ?

                            Multithreading is not really a simple topic. Though... First, the timer must
                            be started in the same thread that created the window containing the label.
                            Second, you need a message loop in the thread you started. Call
                            "Application.Ru n(Form2)" after showing the form. Otherwise the thread
                            terminates when the end of the thread's main procedure (sub mysub) is
                            reached, implicitly destroying the forms created within. Third, you must
                            close the Form after filling the dataset. Fourth, you must call the Form's
                            Invoke method to do this because Form's may only be accessed from the thread
                            that created it.

                            Armin

                            Comment

                            • giannis

                              #15
                              Re: blinking label

                              Armin Zingler wrote:
                              Though... First, the timer must be started in the same thread that created
                              the window containing the label.
                              Sub mySub()
                              Form2.Show()

                              Form2.Refresh()

                              Form2.Timer1.St art()


                              End Sub
                              >Second, you need a message loop in the thread
                              you started. Call "Application.Ru n(Form2)" after showing the form.
                              Otherwise the thread terminates when the end of the thread's main
                              procedure (sub mysub) is reached, implicitly destroying the forms
                              created within.
                              I receive the error : "Starting a second message loop on a single thread is
                              not a valid operation. "
                              when i write :

                              Sub mySub()

                              Form2.Show()

                              Form2.Refresh()

                              Form2.Timer1.St art()

                              Application.Run (Form2)

                              End Sub

                              What can i write ?

                              Please can you write some code for me so i understand this important topic ?

                              Thank you very much for your care !!!


                              Comment

                              Working...