How can i make a blinking label ? Is this possible ?
blinking label
Collapse
This topic is closed.
X
X
-
giannisTags: None -
lord.zoltar@gmail.com
Re: blinking label
On Feb 8, 12:14 pm, "giannis" <zzzinob...@fre email.grwrote:Never tried this, but you could have a timer, and for each tick event,How can i make a blinking label ? Is this possible ?
change the visibility (or colour, or whatever) of the label in
question.
-
Herfried K. Wagner [MVP]
Re: blinking label
<lord.zoltar@gm ail.comschrieb:This should work. For Windows Forms applications,>>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.
'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
Re: blinking label
Herfried K. Wagner [MVP] wrote:I wrote at the Tick event the :This should work. For Windows Forms applications,
'System.Windows .Forms.Timer' (available in the toolbox) is the right
choice.
Me.Label.Visibl e = Not Me.Label.Visibl e
but nothing happened :(
Comment
-
Armin Zingler
Re: blinking label
"giannis" <zzzinobios@fre email.grschriebIs the line executed? Did you start the Timer (calling start method orHerfried 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 :(
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.
Re: blinking label
Hi,
also ensure that the value for the timer is not too low (keep in mind>>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.
it's milliseconds, so a value of 1000 represents 1 second).
Best regards,
Martin
Comment
-
giannis
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 -
giannis -
Armin Zingler
Re: blinking label
"giannis" <zzzinobios@fre email.grschriebthe 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
Re: blinking label
Armin Zingler wrote:At your previous post you say :See my explanation in my previous post. I also mentioned how to solve it.
"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
Re: blinking label
"giannis" <zzzinobios@fre email.grschriebI hope these topics are also available in your language in your local helpArmin 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...
(<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
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
Re: blinking label
"giannis" <zzzinobios@fre email.grschriebThe 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
Re: blinking label
Armin Zingler wrote:Sub mySub()Though... First, the timer must be started in the same thread that created
the window containing the label.
Form2.Show()
Form2.Refresh()
Form2.Timer1.St art()
End Sub
I receive the error : "Starting a second message loop on a single thread is>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.
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
Comment