By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,081 Members | 1,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,081 IT Pros & Developers. It's quick & easy.

Invoking a tooltip from a secundary thread

P: n/a
Hello everybody,

Iīve got a problem thatīs slightly complicated (at least to me it
seems) so I will try to state it as clearly as possible.

At a certain point in time, I start a second thread that runs one of
my functions. The function in this second raises events. As you might
know, the eventhandler for this event is executed within this second
thread and not within the first. Itīs not possible to update
properties of a user control (like a label) that was created in the
first thread, from a second thread. Now .NET has this neat little
invoke() method on their controls, so that you can still use delegates
to update these controls.

So far so good.

However, I run into problems with one special object: a ToolTip
instance. I want the eventhandler, executed by the second thread, to
display a tooltip. However, there is no invoke() method on the
tooltip, and that makes invoking it quite hard. Calling it directly
doesnīt work either.

Does anyone have a solution for this so that I can still show this
tooltip?

Kind regards,
Thijs Brilleman
Feb 11 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You could :
- configure the tooltip so that it is displayed automatically when hovering
the control if applicable
- if you want to display explicitely the tool tip, you can use whatever
Invoke method is available. AFAIK having Invoke on all controls is a
convenience to avoid going always to the parent form but calling invoke on
any control that belongs to the form (or the Form.Invoke method) will always
call on the same UI thread...

--
Patrice

"Thijs" <th*************@gmail.coma écrit dans le message de news:
ab**********************************...oglegroups.com...
Hello everybody,

Iīve got a problem thatīs slightly complicated (at least to me it
seems) so I will try to state it as clearly as possible.

At a certain point in time, I start a second thread that runs one of
my functions. The function in this second raises events. As you might
know, the eventhandler for this event is executed within this second
thread and not within the first. Itīs not possible to update
properties of a user control (like a label) that was created in the
first thread, from a second thread. Now .NET has this neat little
invoke() method on their controls, so that you can still use delegates
to update these controls.

So far so good.

However, I run into problems with one special object: a ToolTip
instance. I want the eventhandler, executed by the second thread, to
display a tooltip. However, there is no invoke() method on the
tooltip, and that makes invoking it quite hard. Calling it directly
doesnīt work either.

Does anyone have a solution for this so that I can still show this
tooltip?

Kind regards,
Thijs Brilleman
Feb 11 '08 #2

P: n/a
Hello Thijs ,

You can just use invokerequired and if returned true use a delegate to
synchronize

i wrote some examples for this newsgroup in the past

1.
http://groups.google.nl/group/micros...f6641d3bedd548
2.
http://groups.google.nl/group/micros...2b4d3823041f08
3.
http://groups.google.nl/group/micros...6308ddc6048859
Wit the examples i show above it should be easy to acomplish what you want ,

HTH

Michel Posseth [MCP]

"Thijs" <th*************@gmail.comschreef in bericht
news:ab**********************************@m34g2000 hsf.googlegroups.com...
Hello everybody,

Iīve got a problem thatīs slightly complicated (at least to me it
seems) so I will try to state it as clearly as possible.

At a certain point in time, I start a second thread that runs one of
my functions. The function in this second raises events. As you might
know, the eventhandler for this event is executed within this second
thread and not within the first. Itīs not possible to update
properties of a user control (like a label) that was created in the
first thread, from a second thread. Now .NET has this neat little
invoke() method on their controls, so that you can still use delegates
to update these controls.

So far so good.

However, I run into problems with one special object: a ToolTip
instance. I want the eventhandler, executed by the second thread, to
display a tooltip. However, there is no invoke() method on the
tooltip, and that makes invoking it quite hard. Calling it directly
doesnīt work either.

Does anyone have a solution for this so that I can still show this
tooltip?

Kind regards,
Thijs Brilleman
Feb 11 '08 #3

P: n/a
Both of you, thanks a lot. The simple solution Patrice offered turned
out to be very effective.

Thijs

On Feb 11, 8:11 pm, "Michel Posseth [MCP]" <MS**@posseth.comwrote:
Hello Thijs ,

You can just use invokerequired and if returned true use a delegate to
synchronize

i wrote some examples for this newsgroup in the past

1.http://groups.google.nl/group/micros...anguages.vb/br...
2.http://groups.google.nl/group/micros...anguages.vb/br...
3.http://groups.google.nl/group/micros...anguages.vb/br....

Wit the examples i show above it should be easy to acomplish what you want,

HTH

Michel Posseth [MCP]

"Thijs" <th*************@gmail.comschreef in berichtnews:ab**********************************@m 34g2000hsf.googlegroups.com...
Hello everybody,

Iīve got a problem thatīs slightly complicated (at least to me it
seems) so I will try to state it as clearly as possible.

At a certain point in time, I start a second thread that runs one of
my functions. The function in this second raises events. As you might
know, the eventhandler for this event is executed within this second
thread and not within the first. Itīs not possible to update
properties of a user control (like a label) that was created in the
first thread, from a second thread. Now .NET has this neat little
invoke() method on their controls, so that you can still use delegates
to update these controls.

So far so good.

However, I run into problems with one special object: a ToolTip
instance. I want the eventhandler, executed by the second thread, to
display a tooltip. However, there is no invoke() method on the
tooltip, and that makes invoking it quite hard. Calling it directly
doesnīt work either.

Does anyone have a solution for this so that I can still show this
tooltip?

Kind regards,
Thijs Brilleman
Feb 12 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.